public IActionResult Add(SpecialAreaDTO spacialArea) { SpacialArea special = new SpacialArea { Name = spacialArea.Name, Description = spacialArea.Description }; SpecialAreaResponse response = _specialAreaService.Add(special); return(response.Code != (int)Constants.ResponseCode.SUCCESS ? StatusCode(500, response) : StatusCode(201, response)); }
public IActionResult Update(SpecialAreaDTO SpacialArea) { SpacialArea sa = new SpacialArea { ID = (int)SpacialArea.ID, Name = SpacialArea.Name, Description = SpacialArea.Description }; SpecialAreaResponse response = _specialAreaService.Update(sa); return(response.Code != (int)Constants.ResponseCode.SUCCESS ? StatusCode(500, response) : StatusCode(200, response)); }
public ProductModelResponse GetSpecialProducts(GetSpecialProductRequest request) { //1 spacialid indirimdeki ürünler sliderına karsılık gelsın ---> ProductModelResponse productResponse = new ProductModelResponse(); try { SpacialArea spacialArea = _repositorySpacial.Get(t => t.ID == request.SpacialID).FirstOrDefault(); if (spacialArea == null) { productResponse.Products = null; productResponse.SetStatus(Constants.ResponseCode.NOT_FOUND_ENTITY); return(productResponse); } int index = (request.PageNumber - 1) * request.Count;//dbde kac kayıt es gecılmeli List <ProductSpacialAreaTable> spacialAreaProducts = _repositorySpacialTable.Get(t => t.SpacialAreaID == spacialArea.ID).Include(t => t.Product).Skip(index).Take(request.Count).ToList(); if (spacialAreaProducts == null) { productResponse.Products = null; productResponse.SetStatus(Constants.ResponseCode.NOT_FOUND_ENTITY); return(productResponse); } List <ProductModel> productList = new List <ProductModel>(); foreach (ProductSpacialAreaTable item in spacialAreaProducts) { productList.Add(new ProductModel { ID = item.Product.ID, Description = item.Product.Description, Price = item.Product.Price, ProductImages = item.Product.ProductImages.Select(t => t.URLFromAway).ToList(), ProductName = item.Product.ProductName, Brand = item.Product.BrandID }); } productResponse.Products = productList; int allcount = _repositorySpacialTable.Get(t => t.SpacialAreaID == spacialArea.ID).Count(); productResponse.PagingInfo = new PagingInfo(request.PageNumber, request.Count, allcount); productResponse.SetStatus(Constants.ResponseCode.SUCCESS); return(productResponse); } catch (Exception ex) { productResponse.Products = null; productResponse.SetStatus(Constants.ResponseCode.FAILED_ON_DB_PROCESS, ex.Message); return(productResponse); } }
public SpecialAreaResponse Add(SpacialArea specialArea) { SpecialAreaResponse response = new SpecialAreaResponse(); try { _repositorySpacial.Add(specialArea); _unitOfWork.SaveChanges(); response.SetStatus(Common.Constants.ResponseCode.SUCCESS); return(response); } catch (Exception ex) { response.SetStatus(Common.Constants.ResponseCode.FAILED_ON_DB_PROCESS, ex.Message); return(response); } }
public BaseResponse AddProductToSpecialByID(int ID) { BaseResponse response = new BaseResponse(); try { SpacialArea spacial = _repositorySpacial.Get(t => t.ID == ID).FirstOrDefault(); spacial.productSpacialAreas.Add(new ProductSpacialAreaTable { ID = spacial.ID }); } catch (Exception) { throw; } throw new NotImplementedException(); }
public SpecialAreaResponse GetSpecialAreaByID(int ID) { SpecialAreaResponse response = new SpecialAreaResponse(); try { SpacialArea spacialarea = _repositorySpacial.Get(t => t.ID == ID).FirstOrDefault(); response.SpecialAreas.Add(new SpecialAreaModel { Name = spacialarea.Name, Description = spacialarea.Description, ID = spacialarea.ID }); response.SetStatus(Common.Constants.ResponseCode.SUCCESS); return(response); } catch (Exception exception) { response.SetStatus(Common.Constants.ResponseCode.FAILED_ON_DB_PROCESS, exception.Message); return(response); } }
public BaseResponse Delete(int ID) { BaseResponse response = new BaseResponse(); try { SpacialArea spacialarea = new SpacialArea { ID = ID }; _repositorySpacial.Delete(spacialarea); _unitOfWork.SaveChanges(); response.SetStatus(Common.Constants.ResponseCode.SUCCESS); return(response); } catch (Exception ex) { response.SetStatus(Common.Constants.ResponseCode.FAILED_ON_DB_PROCESS, ex.Message); return(response); } }