public OperationResult <int> addItem(IItemDTO category) { OperationResult <int> retVal = null; try { EmployeePortalValidationResult validationResult = Validator <ItemManagerValidator, IItemDTO> .Validate(category); if (!validationResult.IsValid) { retVal = OperationResult <int> .CreateFailureResult(validationResult); } else { IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC); int employeeId = employeeManagerDAC.addItem(category); retVal = OperationResult <int> .CreateSuccessResult(employeeId); } } catch (DACException dacEx) { retVal = OperationResult <int> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult <int> .CreateErrorResult(ex.Message, ex.StackTrace); } return(retVal); }
public IList <IItemDTO> GetAllSubCategoryItems(int categoryId) { IList <IItemDTO> employeeDTOList = new List <IItemDTO>(); IItemDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = (employeePortalEntities.Items).Where(item => item.SubCategotyId == categoryId); foreach (var emp in employeeEntity) { employeeDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item); EntityConverter.FillDTOFromEntity(emp, employeeDTO); employeeDTOList.Add(employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(employeeDTOList); }
private static void editItem() { IItemDTO itemDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item, null); itemDTO.ItemName = "item"; itemDTO.ItemId = 1; itemDTO.SubCategotyId = 2; IEcommerceManagerFacade itemManagerFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager, null); OperationResult <bool> operationResult = itemManagerFacade.EditItem(itemDTO); if (operationResult.IsValid()) { System.Console.WriteLine("Updated"); } else if (operationResult.HasValidationFailed() && operationResult.ValidationResult != null) { foreach (EmployeePortalValidationFailure error in operationResult.ValidationResult.Errors) { System.Console.WriteLine(error.PropertyName + " " + error.ErrorMessage); } } else if (operationResult.Message != String.Empty && operationResult.StackTrace != String.Empty) { System.Console.WriteLine(operationResult.Message + " " + operationResult.StackTrace); } }
public bool EditItem(IItemDTO item) { bool retVal = false; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = employeePortalEntities.Items.FirstOrDefault(employee => employee.ItemId == item.ItemId); if (employeeEntity != null) { employeeEntity.SubCategotyId = item.SubCategotyId; employeeEntity.ItemName = item.ItemName; employeePortalEntities.SaveChanges(); retVal = true; } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(retVal); }
public OperationResult<int> addItem(IItemDTO category) { OperationResult<int> retVal = null; try { EmployeePortalValidationResult validationResult = Validator<ItemManagerValidator, IItemDTO>.Validate(category); if (!validationResult.IsValid) { retVal = OperationResult<int>.CreateFailureResult(validationResult); } else { IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC); int employeeId = employeeManagerDAC.addItem(category); retVal = OperationResult<int>.CreateSuccessResult(employeeId); } } catch (DACException dacEx) { retVal = OperationResult<int>.CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult<int>.CreateErrorResult(ex.Message, ex.StackTrace); } return retVal; }
public ActionResult EditItem(Item item) { item.ItemId = updateItemId; IEcommerceManagerFacade employeeFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager); IItemDTO itemDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item); itemDTO.ItemId = item.ItemId; itemDTO.ItemName = item.ItemName; itemDTO.SubCategotyId = item.SubCategotyId; OperationResult <bool> result = employeeFacade.EditItem(itemDTO); JsonResult retVal; if (result.IsValid()) { retVal = new JsonResult() { Data = "Sucessfully Updated", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } else { retVal = new JsonResult() { Data = "Not Updated", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } return(retVal); }
public Item(IServiceProxyFactory serviceProxyFactory, IItemDTO dto) { this.serviceProxyFactory = serviceProxyFactory; this.ID = dto.ID; this.Name = dto.Name; this.ParameterA = dto.ParameterA; this.ParameterB = dto.ParameterB; this.Product = dto.Product; }
public IResult <IItem> CreateItem(IItemDTO dto) { IResult <IItem> res = new Result <IItem>(); IItem o = new Models.Item(this.serviceProxyFactory, dto); res.IsSuccessful = true; res.Message = ""; res.Method = "CreateItem"; res.Result = o; return(res); }
public ActionResult AddItem(Item item) { ActionResult retVal = null; if (ModelState.IsValid) { item.SubCategotyId = addItemcategoryId; IEcommerceManagerFacade employeeFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager); IItemDTO itemDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item); itemDTO.ItemName = item.ItemName; itemDTO.SubCategotyId = item.SubCategotyId; OperationResult <int> result = employeeFacade.addItem(itemDTO); if (result.IsValid()) { retVal = new JsonResult() { Data = "Sucessfully Added", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } else if (result.HasValidationFailed() && result.ValidationResult != null) { this.HandleValidationFailure(result); return(AddItem(addItemcategoryId)); } else { OperationResult <int> succes = OperationResult <int> .CreateFailureResult("Item can't be added. Please try after sometime."); succes.IsValid(); retVal = new JsonResult() { Data = succes }; } } else { retVal = new JsonResult() { Data = "Not Added", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } return(retVal); }
public int addItem(IItemDTO category) { int retVal = default(int); using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { Item employee = new Item(); EntityConverter.FillEntityFromDTO(category, employee); Item addedEmployee = employeePortalEntities.Items.Add(employee); employeePortalEntities.SaveChanges(); retVal = addedEmployee.ItemId; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(retVal); }
public int addItem(IItemDTO category) { int retVal = default(int); using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { Item employee = new Item(); EntityConverter.FillEntityFromDTO(category, employee); Item addedEmployee = employeePortalEntities.Items.Add(employee); employeePortalEntities.SaveChanges(); retVal = addedEmployee.ItemId; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public OperationResult <IItemDTO> getItem(int employeeId) { OperationResult <IItemDTO> retVal = null; try { IEcommerceManagerDAC employeeManagerDAC = (IEcommerceManagerDAC)DACFactory.Instance.Create(DACType.EcommerceManagerDAC); IItemDTO employeeDTO = employeeManagerDAC.getItem(employeeId); retVal = OperationResult <IItemDTO> .CreateSuccessResult(employeeDTO); } catch (DACException dacEx) { retVal = OperationResult <IItemDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace); } catch (Exception ex) { ExceptionManager.HandleException(ex); retVal = OperationResult <IItemDTO> .CreateErrorResult(ex.Message, ex.StackTrace); } return(retVal); }
public IItemDTO getItem(int employeeId) { IItemDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = employeePortalEntities.Items.FirstOrDefault(employee => employee.ItemId == employeeId); if (employeeEntity != null) { employeeDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item); EntityConverter.FillDTOFromEntity(employeeEntity, employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(employeeDTO); }
public OperationResult <bool> EditItem(IItemDTO item) { IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager); return(employeeManagerBDC.EditItem(item)); }
public bool EditItem(IItemDTO item) { bool retVal = false; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = employeePortalEntities.Items.FirstOrDefault(employee => employee.ItemId == item.ItemId); if (employeeEntity != null) { employeeEntity.SubCategotyId = item.SubCategotyId; employeeEntity.ItemName = item.ItemName; employeePortalEntities.SaveChanges(); retVal = true; } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public OperationResult <int> addItem(IItemDTO category) { IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager); return(employeeManagerBDC.addItem(category)); }
public OperationResult<bool> EditItem(IItemDTO item) { IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager); return employeeManagerBDC.EditItem(item); }
public OperationResult<int> addItem(IItemDTO category) { IEcommerceManagerBDC employeeManagerBDC = (IEcommerceManagerBDC)BDCFactory.Instance.Create(BDCType.EcommerceManager); return employeeManagerBDC.addItem(category); }