Ejemplo n.º 1
0
        //-> New
        public async Task <SourceSupplyViewDTO> New(SourceSupplyNewDTO newDTO)
        {
            newDTO = StringHelper.TrimStringProperties(newDTO);
            var record = (tblSourceOfSupply)MappingHelper.MapDTOToDBClass <SourceSupplyNewDTO, tblSourceOfSupply>(newDTO, new tblSourceOfSupply());

            //record.createdDate = DateTime.Now;
            db.tblSourceOfSupplies.Add(record);
            await db.SaveChangesAsync();

            db.Entry(record).Reload();
            return(await SelectByID(record.id));
        }
 public async Task <JsonResult> New(SourceSupplyNewDTO newDTO)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             throw new HttpException((int)HttpStatusCode.BadRequest, ConstantHelper.KEY_IN_REQUIRED_FIELD);
         }
         Response.StatusCode = 200;
         return(Json(await handler.New(newDTO), JsonRequestBehavior.AllowGet));
     }
     catch (HttpException)
     {
         return(Json(ConstantHelper.ERROR, JsonRequestBehavior.AllowGet));
     }
 }