Пример #1
0
 public async Task Upsert(Ivhunim ivhun)
 {
     try
     {
         using (IvhunimEntities entities = new IvhunimEntities())
         {
             entities.Entry(ivhun).State = System.Data.Entity.EntityState.Modified;
             await entities.SaveChangesAsync();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
 public async Task Post(Ivhunim ivhun)
 {
     try
     {
         using (IvhunimEntities entities = new IvhunimEntities())
         {
             entities.Ivhunims.Add(ivhun);
             await entities.SaveChangesAsync();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #3
0
 public async Task <IHttpActionResult> Upsert(int id, [FromBody] Ivhunim ivhun)
 {
     try
     {
         string email = User.Identity.Name;
         if (id > -1)
         {
             ivhun.Id = id;
             await _ivhunRpo.Upsert(ivhun);
         }
         else
         {
             await _ivhunRpo.Post(ivhun);
         }
         return(Ok(_ivhunRpo.GetAll(User.IsInRole("Admin"), User.IsInRole("NextStepAdmin"), User.IsInRole("Typist"), email)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }