public HttpResponseMessage Post([FromBody] SchemeMasterViewModel schemeMaster)
        {
            if (ModelState.IsValid)
            {
                if (_schemeMaster.CheckSchemeNameExists(schemeMaster.SchemeName))
                {
                    var response = new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.Conflict
                    };

                    return(response);
                }
                else
                {
                    var userId = this.User.FindFirstValue(ClaimTypes.Name);

                    var tempSchemeMaster = AutoMapper.Mapper.Map <SchemeMaster>(schemeMaster);
                    tempSchemeMaster.Createddate = DateTime.Now;
                    tempSchemeMaster.Createdby   = Convert.ToInt32(userId);
                    _schemeMaster.AddSchemeMaster(tempSchemeMaster);

                    var response = new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.OK
                    };

                    return(response);
                }
            }
            else
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                };

                return(response);
            }
        }
示例#2
0
        public IActionResult Post([FromBody] SchemeMasterViewModel schemeMaster)
        {
            if (ModelState.IsValid)
            {
                if (_schemeMaster.CheckSchemeNameExists(schemeMaster.SchemeName))
                {
                    return(Conflict());
                }
                else
                {
                    var userId = this.User.FindFirstValue(ClaimTypes.Name);

                    var tempSchemeMaster = AutoMapper.Mapper.Map <SchemeMaster>(schemeMaster);
                    tempSchemeMaster.CreatedDate = DateTime.Now;
                    tempSchemeMaster.CreatedBy   = Convert.ToInt32(userId);
                    _schemeMaster.AddSchemeMaster(tempSchemeMaster);
                    return(Ok());
                }
            }
            else
            {
                return(BadRequest());
            }
        }