public Operation <StaffModel> CreateStaff(StaffModel model) { return(System.Operation.Create(() => { try { var isExists = _context.Staffs.Where(c => c.Name == model.Name /*c.StaffName == model.StaffName &&*//* c.StaffNo == model.StaffNo*/).FirstOrDefault(); if (isExists != null) { throw new Exception("user email already exist"); } //var exist = _context.Staffs.Where(e => e.StaffNo == model.StaffNo).FirstOrDefault(); //if (exist != null) throw new Exception("user staffno already exist"); var entity = model.Create(model); _context.Staffs.Add(entity); _context.SaveChanges(); } catch (Exception xe) { throw xe; } //model.Validate(); return model; })); }