Exemplo n.º 1
0
        internal string GetBusinessCategoryName(int id)
        {
            BusinessCategoryService   businessCategoryService = new BusinessCategoryService();
            BusinessCategoryViewModel businessName            = businessCategoryService.getBusinessCategoryName(id);

            return(businessName.CategoryName);
        }
Exemplo n.º 2
0
        public BusinessCategoryViewModel getBusinessCategoryName(int id)
        {
            BusinessCategoryViewModel data = (from s in businessCategoryRepository.Get()
                                              where s.CategoryId == id
                                              // join d in dropDownTypeRepository.Get() on s.DropDownTypeID equals d.DropDownTypeID
                                              select new BusinessCategoryViewModel
            {
                CategoryName = s.CategoryName,
            }).SingleOrDefault();

            return(data);
        }
        // PUT: api/businesscategory/5
        public IHttpActionResult Put(long?id, [FromBody] BusinessCategoryViewModel model)
        {
            try
            {
                if (!id.HasValue)
                {
                    return(Ok(new { status = false, data = "", message = "Please provide a valid business category id." }));
                }
                else
                {
                    var businessCategory = _db.tblBusinessCategories.Find(id);
                    if (businessCategory != null)
                    {
                        businessCategory.Description     = model.Description;
                        businessCategory.IsActive        = model.IsActive;
                        businessCategory.Name            = model.Name;
                        businessCategory.OrderNumber     = model.OrderNumber;
                        businessCategory.ParentId        = model.ParentId;
                        businessCategory.PictureLink     = model.PictureLink;
                        businessCategory.Type            = model.Type;
                        businessCategory.AdministratorId = model.AdministratorId;

                        _db.Entry(businessCategory).State = EntityState.Modified;
                        var response = _db.SaveChanges();
                        if (response > 0)
                        {
                            return(Ok(new { status = true, data = businessCategory, message = "Transaction successed." }));
                        }
                        else
                        {
                            return(Ok(new { status = false, data = "", message = "Transaction failed." }));
                        }
                    }
                    else
                    {
                        return(Ok(new { status = false, data = "", message = "Not a valid data to update. Please provide a valid information." }));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
            }
        }
 // POST: api/businesscategory
 public IHttpActionResult Post([FromBody] BusinessCategoryViewModel model)
 {
     try
     {
         if (model != null)
         {
             var businessCategory = new tblBusinessCategory()
             {
                 Created         = DateTime.Now.ToUniversalTime(),
                 Description     = model.Description,
                 IsActive        = model.IsActive,
                 Name            = model.Name,
                 OrderNumber     = model.OrderNumber,
                 ParentId        = model.ParentId,
                 PictureLink     = model.PictureLink,
                 Type            = model.Type,
                 AdministratorId = model.AdministratorId
             };
             _db.tblBusinessCategories.Add(businessCategory);
             var response = _db.SaveChanges();
             if (response > 0)
             {
                 return(Ok(new { status = true, data = businessCategory, message = "Transaction successed." }));
             }
             else
             {
                 return(Ok(new { status = false, data = "", message = "Transaction failed." }));
             }
         }
         else
         {
             return(Ok(new { status = false, data = "", message = "Please provide a valid information." }));
         }
     }
     catch (Exception ex)
     {
         return(Ok(new { status = false, data = "", message = "ex: " + ex.Message.ToString() }));
     }
 }