public async Task <Guid> Save(APIIntegrationDTO _Dto, Guid Id, int EntityState) { APIIntegration _APIIntegration = new APIIntegration(); if (_Dto != null) { _APIIntegration.Id = Id; _APIIntegration.Name = _Dto.Name; _APIIntegration.URL = _Dto.URL; _APIIntegration.UserName = _Dto.UserName; _APIIntegration.Password = PasswordManager.DecryptText(_Dto.Password); _APIIntegration.StatusCode = EMPConstants.Active; } if (_Dto.Id != null) { _APIIntegration.CreatedBy = _Dto.UserId; _APIIntegration.CreatedDate = DateTime.Now; _APIIntegration.LastUpdatedBy = _Dto.UserId; _APIIntegration.LastUpdatedDate = DateTime.Now; } else { _APIIntegration.LastUpdatedBy = _Dto.UserId; _APIIntegration.LastUpdatedDate = DateTime.Now; } if (EntityState == (int)System.Data.Entity.EntityState.Modified) { db.Entry(_APIIntegration).State = System.Data.Entity.EntityState.Modified; } else { db.APIIntegrations.Add(_APIIntegration); } try { await db.SaveChangesAsync(); return(_APIIntegration.Id); } catch (DbUpdateConcurrencyException) { if (!IsExists(_APIIntegration.Id)) { return(_APIIntegration.Id); } else { throw; } } }
public HomeController() { api = APIIntegration.GetAPIInstance(); }