public ActionResult AddOrUpdateRecordType(Guid?id, string typeName, int subTypeId) { Guid UID = Guid.NewGuid(); if (id != null) { UID = (Guid)id; } RecordTypeDM newRecord = new RecordTypeDM() { Id = UID, CreatedBy = User.Identity.GetUserId(), CreatedDate = DateTime.Now, IsDeleted = false, IsEnabled = true, ModifiedBy = User.Identity.GetUserId(), ModifyDate = DateTime.Now, Name = typeName, SubType = subTypeId }; var result = Services.DataServices.AppAdministrator.AppAdministratorDMM.InsertOrUpdateRecordType(newRecord); return(Json(result, JsonRequestBehavior.AllowGet)); }
public static ActionHandler InsertOrUpdateRecordType(RecordTypeDM record) { ActionHandler result = new ActionHandler { IsSuccess = true, Message = "" }; try { using (TardiRecordsEntities db = new DataLayer.TardiRecordsEntities()) { var item = db.RecordType.SingleOrDefault(x => x.id == record.Id); if (item == null) { RecordType RT = new RecordType(); RT.id = record.Id; RT.isDeleted = false; RT.isEnabled = true; RT.name = record.Name; RT.subType = record.SubType; RT.createdBy = record.CreatedBy; RT.createdDate = DateTime.Now; RT.modifiedBy = record.ModifiedBy; RT.modifyDate = DateTime.Now; db.RecordType.Add(RT); db.SaveChanges(); } else { item.name = record.Name; item.subType = record.SubType; item.modifiedBy = record.ModifiedBy; item.modifyDate = DateTime.Now; db.SaveChanges(); } } } catch (Exception ex) { result.IsSuccess = false; result.Message = ex.Message; } return(result); }