public string updatexlinkdetails(xlinkModel model) { try { db = new DatabaseEntities(); var isexist = (from s in db.UtaxCrosslinkDetails where s.CLAccountId == model.CLAccountId && s.StatusCode == EMPConstants.Active select s).FirstOrDefault(); if (model.Id == 0) { if (isexist != null) return "Exists"; UtaxCrosslinkDetail detail = new UtaxCrosslinkDetail(); detail.CreatedBy = model.UserId; detail.CreatedDate = DateTime.Now; detail.Password = model.Password == "" ? "" : PasswordManager.CryptText(model.Password); detail.StatusCode = EMPConstants.Active; detail.CLAccountId = model.CLAccountId; detail.CLAccountPassword = PasswordManager.CryptText(model.CLAccountPassword); detail.CLLogin = model.CLLogin; detail.UpdatedBy = model.UserId; detail.UpdatedDate = DateTime.Now; detail.Username = model.MasterId; db.UtaxCrosslinkDetails.Add(detail); db.SaveChanges(); } else if (model.Id != 0) { if (isexist != null) { if (isexist.Id != model.Id) return "Exists"; } var data = db.UtaxCrosslinkDetails.Where(x => x.Id == model.Id).FirstOrDefault(); if (data != null) { data.Username = model.MasterId; data.Password = model.Password == "" ? "" : PasswordManager.CryptText(model.Password); data.StatusCode = EMPConstants.Active; data.CLAccountId = model.CLAccountId; data.CLAccountPassword = PasswordManager.CryptText(model.CLAccountPassword); data.CLLogin = model.CLLogin; data.UpdatedBy = model.UserId; data.UpdatedDate = DateTime.Now; db.SaveChanges(); } } return "Success"; } catch (Exception) { return "Fail"; } }
public string InactiveAccount(xlinkModel model) { try { db = new DatabaseEntities(); if (model.Id != 0) { if (model.status == "Inactive") { var isexist = (from s in db.UtaxCrosslinkDetails where s.CLAccountId == model.CLAccountId && s.StatusCode == EMPConstants.Active && s.Id != model.Id select s).FirstOrDefault(); if (isexist != null) return "Exists"; } var data = db.UtaxCrosslinkDetails.Where(x => x.Id == model.Id).FirstOrDefault(); if (data != null) { data.StatusCode = model.status == "Active" ? EMPConstants.InActive : EMPConstants.Active; data.UpdatedBy = model.UserId; data.UpdatedDate = DateTime.Now; db.SaveChanges(); return "success"; } else return "Fail"; } else return "Fail"; } catch (Exception) { return "Fail"; } }
public IHttpActionResult Putxlinkdetails(xlinkModel model) { var details = _UserService.InactiveAccount(model); return(Ok(details)); }
public IHttpActionResult Postxlinkdetails(xlinkModel model) { var details = _UserService.updatexlinkdetails(model); return(Ok(details)); }