public ActionResult Create(Product prod) { try { // TODO: Add insert logic here rep.Add(prod); return(new HttpStatusCodeResult(System.Net.HttpStatusCode.OK)); } catch { return(View()); } }
/// <summary> /// Gönderilen Entityi veritabanına ekler. Eğer save parametresi false olarak gönderilirse bu işlemden sonra verinin veritabanına eklenebilmesi için Save() yapılması gerekir. /// </summary> /// <param name="entity"></param> /// <param name="save"></param> public virtual void Add(T entity, bool save = true) { try { _repository.Add(entity); if (save) { _unitOfWork.Save(); } } catch (Exception exc) { throw exc; } }
public Department AddDepartment(Department department) { if (department == null) { throw new NullReferenceException("Department object cannot be null."); } if (string.IsNullOrEmpty(department.Name)) { throw new ArgumentNullException("Department name must be entered."); } department.CreatedDate = DateTime.Now; department.CreatedBy = WindowsIdentity.GetCurrent().Name; var dept = _repository.Add(department); _repository.SaveAll(); return(dept); }
public Employee AddEmployee(Employee employee) { if (employee == null) { throw new NullReferenceException("Employee object cannot be null."); } if (string.IsNullOrEmpty(employee.Name)) { throw new ArgumentNullException("Employee name cannot be null."); } employee.CreatedDate = DateTime.Now; employee.CreatedBy = WindowsIdentity.GetCurrent().Name; var result = _repository.Add(employee); _repository.SaveAll(); return(result); }