public bool CreateDept(DepartmentModel model) { try { var isExist = _context.Departments.Where(x => x.DeptName == model.DeptName).FirstOrDefault(); if (isExist != null) { throw new Exception("Department already exist"); } var entity = model.Create(model); _context.SaveChanges(); } catch (Exception xe) { throw xe; } return(true); }