Beispiel #1
0
        /// <summary>
        /// Get information of a brand
        /// </summary>
        /// <param name="id">id of brand</param>
        /// <returns>return a view model to display on client side</returns>
        public Model.ViewModel.DetailsBrandManagementView GetDetailBrand(int id)
        {
            ecom_Brands brand = db.GetByID(id);
            if (brand == null) { throw new ArgumentNullException(); }
            // Get user create brand and user last time modified brand 
            system_Profiles createBy = systemProfiles.GetByID(brand.CreatedBy);
            system_Profiles modifiredBy = systemProfiles.GetByID(brand.CreatedBy);

            return brand.ConvertToDetailsBrandView(createBy != null ? createBy.UserName : "", modifiredBy != null ? modifiredBy.UserName : "");
        }
Beispiel #2
0
        public static BrandSummaryView ConvertToBrandSummaryView(ecom_Brands brand)
        {
            var brandSummaryView = new BrandSummaryView()
            {
                Id   = brand.Id,
                Name = brand.Name
            };

            return(brandSummaryView);
        }
Beispiel #3
0
        public static ecom_Brands ConvertToBrandModel(EditBrandManagementPostRequest brandView)
        {
            var returnModel = new ecom_Brands()
            {
                Id          = brandView.Id,
                Name        = brandView.Name,
                Status      = brandView.Status,
                Description = brandView.Description
            };

            return(returnModel);
        }
Beispiel #4
0
        public static ecom_Brands ConvertToBrandModel(CreateBrandPostRequest brandRequest)
        {
            var brand = new ecom_Brands()
            {
                Id          = brandRequest.Id,
                Name        = brandRequest.Name,
                Status      = brandRequest.Status,
                Description = brandRequest.Description
            };

            return(brand);
        }
 /// <summary>
 /// Add new brand
 /// </summary>
 /// <param name="brand">information of new brand</param>
 /// <returns></returns>
 public bool AddBrand(ecom_Brands brand)
 {
     try
     {
         db.Insert(brand);
         db.Save();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 /// <summary>
 /// Update information of brand
 /// </summary>
 /// <param name="brand"></param>
 /// <returns></returns>
 public bool UpdateBrand(ecom_Brands brand)
 {
     try
     {
         db.Update(brand);
         db.Save();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #7
0
        /// <summary>
        /// Create GUI for edit a brand
        /// </summary>
        /// <param name="id">id of brand, which need to update</param>
        /// <returns></returns>
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ecom_Brands brand = brandService.GetBrandById((int)id);

            if (brand == null)
            {
                return(HttpNotFound());
            }
            PopulateStatusDropDownList((Define.Status)brand.Status);
            return(View(brand.ConvertToEditBrandManagementGetResponse()));
        }
 /// <summary>
 /// Delete brand
 /// </summary>
 /// <param name="id">id of brand</param>
 /// <returns></returns>
 public bool DeleteBrand(int id)
 {
     try
     {
         ecom_Brands brand = db.GetByID(id);
         brand.Status = (int)Define.Status.Delete;
         db.Update(brand);
         db.Save();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #9
0
        public static DetailsBrandManagementView ConvertToDetailsBrandView(ecom_Brands brand, string createBy, string modifiredBy)
        {
            DetailsBrandManagementView returnView = new DetailsBrandManagementView()
            {
                Id           = brand.Id,
                Name         = brand.Name,
                Status       = EnumHelper.GetDescriptionFromEnum((Define.Status)brand.Status),
                Description  = brand.Description,
                CreatedBy    = createBy,
                CreatedDate  = string.Format("{0:yyyy-MM-dd}", brand.CreatedDate),
                ModifiedBy   = modifiredBy,
                ModifiedDate = string.Format("{0:yyyy-MM-dd}", brand.ModifiedDate)
            };

            return(returnView);
        }
Beispiel #10
0
        public static EditBrandManagementGetResponse ConvertToEditBrandManagementGetResponse(ecom_Brands brand)
        {
            var returnModel = new EditBrandManagementGetResponse()
            {
                Id          = brand.Id,
                Name        = brand.Name,
                Status      = (int)brand.Status,
                Description = brand.Description
            };

            return(returnModel);
        }
        /// <summary>
        /// Get information of brand
        /// </summary>
        /// <param name="id">id of brand</param>
        /// <returns></returns>
        public ecom_Brands GetBrandById(int id)
        {
            ecom_Brands brand = db.GetByID(id);

            return(brand);
        }