小编Nir*_*ole的帖子

如何为SQL表列分配2个默认值?

我正在设计下面列的用户注册表.

CREATE TABLE [dbo].[NCT_UserRegistration]
(
    [User_Id] [int] IDENTITY(1,1) NOT NULL,
    [User_EmailId] [varchar](255) NULL,
    [User_Password] [varchar](512) NULL,
    [User_Name] [varchar](255) NULL,
    [User_MobileNum] [varchar](20) NULL,
    [User_Status] [varchar](15) NULL,
    [User_Role] [varchar](20) NULL,
    [User_CreatedDate] [timestamp] NULL,
    [User_UpdatedDate] [datetime] NULL,
    [Name] [varchar](30) NULL
)
Run Code Online (Sandbox Code Playgroud)

我对地位和角色的要求如下.

  • status VARCHAR(15) 指数,已启用的枚举,已禁用.
  • role VARCHAR(20) SUPER_ADMIN和PROJECT_ADMIN的枚举

我从上面所理解的是状态应该只与角色相同EnabledDisabled相同.如何设计我的表以确保它只需要这两个值?也有任何方式,例如,如果我提供1然后它是ENABLED和0为DISABLED.

我可以在这里得到一些想法吗?任何帮助,将不胜感激.谢谢

sql sql-server alter-table

6
推荐指数
1
解决办法
3229
查看次数

如何在 Web API 2 的 IHttpActionResult 中添加标头?

嗨,我正在使用 Web API 2 开发 API。我知道如何在使用HttpResponseMessage. 现在我正在使用IHttpActionResult.

下面是我的示例当前代码。

return Content(HttpStatusCode.OK, LoginResponse);
Run Code Online (Sandbox Code Playgroud)

返回内容时如何添加标题?

每当我使用时,HttpResponseMessage我都会有请求对象,并且可以添加标头。

下面的代码我在HttpResponseMessage.

response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
response.Headers.AddCookies(new[] { cookie });
return response;
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我可以在哪里添加标题值?

.net c# asp.net-web-api asp.net-web-api2

5
推荐指数
2
解决办法
6472
查看次数

如何将javascript日期转换为hijri格式?

嗨,我正在 Angularjs/JavaScript 中开发 Web 应用程序。我有一个日历选择器,我正在从前端捕获日期。在数据库中保存所选日期时,我想以回历格式保存。我遵循将公历日期转换为回历日期,当我在 writeIslamicDate 中传递 1 时它工作正常。例如:

var today=new Date();
writeIslamicDate(today);
Run Code Online (Sandbox Code Playgroud)

如果我通过今天的日期那么它给了我undefined, NaN undefined NaN AH所以我可以知道在将输入传递给 writeIslamicDate 之前我是否需要转换为任何格式?有人可以帮助我吗?任何帮助,将不胜感激。谢谢你。

javascript date angularjs

4
推荐指数
2
解决办法
8025
查看次数

如何在mvc4 c#中减少nullable int by1?

我有一个动作方法如下:

public PartialViewResult batchSave(int? clientId, string uploadidList, int? currentFilter, int? page)
{
    if(page!=null)
    {
        page--;// This is also not working
        page=page-1; //Does not works
    } 
}
Run Code Online (Sandbox Code Playgroud)

我尝试了如上,但它没有减少.基本上它是可以为空的; 那有什么方法可以解决这个问题吗?谢谢

c# asp.net-mvc-4

3
推荐指数
1
解决办法
158
查看次数

如何删除mvc4文本框中的默认日期?

我在mvc4应用程序中有一个文本框,如下所示.

@Html.TextBoxFor(x=>x.dateofAction, ViewBag.filterdateTime as string,  new { @id = "dateofAction", @placeholder = "Date Of Action", @class = "txtBox form-control calender validate[required]" })
Run Code Online (Sandbox Code Playgroud)

我在这个文本框中使用jquery日历.

 $(document).on('focus', '.calender', function(){
         $(this).datepicker({

             dateFormat: "dd/mm/yy",
             changeMonth: true,
             changeYear: true,
             showOn: 'button',
             buttonImage: '/images/icondate.png',
             buttonImageOnly: true
        })
            });
Run Code Online (Sandbox Code Playgroud)

这是我的模特

 [DisplayName("dateofAction")]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
        public DateTime dateofAction { get; set; }
Run Code Online (Sandbox Code Playgroud)

第一次页面加载默认日期1/1/0001 12:00:00 AM显示在文本框中时,我遇到问题.其实我想显示占位符值.

我可以知道为什么我无法获得占位符价值吗?

c# asp.net-mvc asp.net-mvc-4

3
推荐指数
1
解决办法
1672
查看次数

如何在Angularjs $ state.go中发送参数?

我正在开发AngularJS应用程序.我正在尝试将值发送$state.go到不同的状态.我正在尝试如下.

这是我的状态:

$stateProvider
.state('Registration.OTPVerification', {
    url: '/RegistrationOTPVerification',
    templateUrl: 'Registration/RegistrationOTP.html',
    controller: 'RegistrationOTPVerification'
});
Run Code Online (Sandbox Code Playgroud)

我正在尝试如下.

var customerid = response.data.ID;
var OTP = response.data.OTP;
$state.go('Registration.OTPVerification', customerid,OTP);
Run Code Online (Sandbox Code Playgroud)

我试图在下面的控制器中接收参数.

(function () {
    angular.module('RoslpApp').controller('RegistrationOTPVerification', ['$scope', '$http', '$translatePartialLoader', '$translate', '$state', function ($scope, $http, $translatePartialLoader, $translate, $state, $stateParams) {
        var customerid = $stateParams.customerid;
        var OTP = $stateParams.OTP;
        alert(customerid);
    }]);
})();
Run Code Online (Sandbox Code Playgroud)

我无法接收参数.任何帮助,将不胜感激.谢谢.

javascript angularjs angular-ui-router

3
推荐指数
1
解决办法
6983
查看次数

如何在linq查询中截断日期时间部分?

您好我正在尝试编写linq查询以从Sql表中获取一些详细信息.我创建了列并存储了日期和时间.回来的时候我想省略时间部分.我可以知道这可能吗?

  List<returnObject> obj = new List<returnObject>();
obj = (from c in objectDB.NCT_Project
  join user in objectDB.NCT_UserRegistration on c.adminUserId equals user.User_Id
  where c.adminUserId == userId
                       select new returnObject
                       {
                           id = c.project_Id,
                           key = c.key,
                           created = c.createdDate //currently returns datetime
                       }).ToList(); 
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.谢谢.

c# linq asp.net-mvc-5

3
推荐指数
1
解决办法
1万
查看次数

获取方法无法在web api中工作

嗨,我正在开发web api2和angularjs中的一个应用程序.从angularjs访问URL时我遇到了一些路由问题.

我试图访问下面的网址.

var url = '/api/projects/4/processes';
Run Code Online (Sandbox Code Playgroud)

我的控制器代码如下所示.

[RoutePrefix("api/processes")]
public class processesController : ApiController
{      
    [ActionName("projects/{projectsId}/processes")]
    public HttpResponseMessage Get(int id)
    {
        return Request.CreateResponse(HttpStatusCode.OK, "");
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到404错误.我无法点击网址.

这是我的webapi.config文件.

config.Routes.MapHttpRoute(
    name: "DefaultApi",
    routeTemplate: "api/{controller}/{id}",
    //routeTemplate: "{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

c# asp.net-web-api asp.net-web-api-routing

2
推荐指数
1
解决办法
4564
查看次数

如何在angularjs中显示错误消息(404)

嗨,我正在使用web api作为前端的angularjs应用程序.每当某个用户没有某些权限时,我就会将Httpresponsemessage作为

var message = string.Format("You do not have permission");
                        HttpError err = new HttpError(message);
                        return Request.CreateResponse(HttpStatusCode.NotFound, err);
Run Code Online (Sandbox Code Playgroud)

我想以角度提醒上面的消息,我正在尝试如下.

$scope.Update = function () {
        var servCall = ProjectSetting_Service.update(sub);
        servCall.then(function (data) {
            alert(JSON.stringify(data));
            });
    }, function (error) {
//How to alert message here

    }
Run Code Online (Sandbox Code Playgroud)

我可以在这里得到一些帮助!任何帮助,将不胜感激.谢谢.

javascript angularjs

0
推荐指数
1
解决办法
580
查看次数

Angularjs中两个按钮的不同验证?

嗨,我有两种形式的HTML控件.以下是我的表格.

<form name="form3" novalidate>
            <fieldset ng-disabled="employementdetails">
            <div class="inputblock" ng-class="{ 'has-error' : ((form3.$submitted && form3.Employer.$invalid)  || (form3.Employer.$invalid && form3.Employer.$dirty))}">
                        <div>
                            <span class="ang-error" style="color:#fff" ng-show="form3.Employer.$invalid && form3.Employer.$error.required && form3.Employer.$dirty">*Required</span>
                        </div>
                        <select ng-model="user.Employer" name="Employer" id="Employer" ng-options="user.ID as user.Employer for user in EmployerList" required>
                            <option value="" label="Employer">Employer</option>
                        </select>
                    </div>
           //some other controls
           <div class="button-container">
                        <input type="submit" value="{{ 'BACK' | translate }}" class="brown-button" ng-click="gotopersonaladdress()">
                        <input type="submit" value="{{ 'NEXT' | translate }}" class="blue-button" ng-click="saveemployementdetails()">
           </div>
          </fieldset>
</form>
Run Code Online (Sandbox Code Playgroud)

每当我点击NEXT时,我的验证工作正常.但是,当我点击BACK按钮时,我不想激活任何验证,我滚动到以前的形式.这不会发生.点击BACK后我的验证也开始了.有什么方法可以禁用它吗?任何帮助,将不胜感激.谢谢.

javascript angularjs

0
推荐指数
1
解决办法
74
查看次数

Angularjs在一个工厂内使用工厂价值

嗨,我正在开发angularjs中的Web应用程序.我有一个带有两个工厂的java脚本文件,它们对web api进行http调用.我想在另一家工厂内使用一个工厂值输出.下面是我的第一家工厂

myapp.factory('sadadpaymentapi', ['$http', '$cookieStore', 'cfg', 'ScrollFunction', 'leaselisting','$q', function ($http, $cookieStore, cfg, ScrollFunction, leaselisting,$q) {
    var sadadpaymentapiobject = {};
    var baseurl = cfg.Baseurl;
    var LoginID = $cookieStore.get("LoginID");
    var cookiePreferredLanguage = $cookieStore.get('PreferredLanguage');
    var urlapi = baseurl + "api/ServiceRequest/CreateRSSedad/";
    sadadpaymentapiobject.callsadad = function (PaymentType) {
        var request = {
            url: urlapi,
            method: 'POST',
            data: {
                SRActivityID: LoginID,
                PaymentType: PaymentType,
                PaymentAmount: "100" //Need to get value from another factory
            },
            headers: ScrollFunction.getheaders()
        };
        return $http(request);
    }
    return sadadpaymentapiobject;
}]); 
Run Code Online (Sandbox Code Playgroud)

下面是另一家工厂,我可以在上面的工厂中获得PaymentAmount参数的值.

myapp.factory('leaselisting', ['$http', '$cookieStore', 'cfg', …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

0
推荐指数
1
解决办法
37
查看次数