Ejemplo n.º 1
0
 public bool EditMyClassifieds(int classifiedId, [FromBody] EditClassifiedModel model)
 {
     if (!_classifiedService.ValidateUserClassified(CurrentUserId, classifiedId))
     {
         throw new HttpResponseException(ErrorMessage("لا يمكنك تعديل هذا الإعلان"));
     }
     return(_classifiedService.EditClassified(model));
 }
Ejemplo n.º 2
0
 public bool EditClassified(EditClassifiedModel model)
 {
     using (var scope = new TransactionScope())
     {
         bool SetAsPending = false;
         var  classified   = _unitOfWork.ClassifiedRepository.FindSingleBy(c => c.Id == model.ClassifiedId);
         if (model.Country != null)
         {
             classified.Country = model.Country;
             classified.City    = model.City;
         }
         if (model.AdType.HasValue)
         {
             classified.AdType = model.AdType.Value;
             if (classified.AdType == AdTypeList.Fixed)
             {
                 classified.AdPrice = model.AdPrice.Value;
             }
             else
             {
                 classified.AdPrice = null;
             }
         }
         if (model.Description != null)
         {
             classified.Description = model.Description;
             SetAsPending           = true;
         }
         if (model.Title != null)
         {
             classified.Title = model.Title;
             SetAsPending     = true;
         }
         if (model.SubCategoryId.HasValue)
         {
             classified.SubCategoryId = model.SubCategoryId.Value;
             SetAsPending             = true;
         }
         if (SetAsPending)
         {
             classified.Status      = AdStatusList.Pending;
             classified.PostingDate = null;
         }
         _unitOfWork.ClassifiedRepository.Edit(classified);
         _unitOfWork.Save();
         scope.Complete();
         return(true);
     }
 }