Ejemplo n.º 1
0
 // /Admin/UpdatePurchaseType
 private static int? CreateSellerType(CookieCollection cookies, string sellerType, out string resp)
 {
     resp = string.Empty;
     int? sellerTypeId = null;
     DeepBlue.Models.Admin.EditSellerTypeModel model = new DeepBlue.Models.Admin.EditSellerTypeModel();
     model.SellerType = sellerType;
     NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(model, string.Empty, string.Empty);
     string url = HttpWebRequestUtil.GetUrl("Admin/UpdateSellerType");
     byte[] postData = System.Text.Encoding.ASCII.GetBytes(HttpWebRequestUtil.ToFormValue(formValues));
     HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies);
     if (response.StatusCode == System.Net.HttpStatusCode.OK) {
         using (Stream receiveStream = response.GetResponseStream()) {
             // Pipes the stream to a higher level stream reader with the required encoding format.
             using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {
                 resp = readStream.ReadToEnd();
                 if (!string.IsNullOrEmpty(resp)) {
                     sellerTypeId = HttpWebRequestUtil.GetNewKeyFromResponse(resp);
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return sellerTypeId;
 }
Ejemplo n.º 2
0
 public ActionResult UpdateSellerType(FormCollection collection)
 {
     EditSellerTypeModel model=new EditSellerTypeModel();
     ResultModel resultModel=new ResultModel();
     this.TryUpdateModel(model);
     string ErrorMessage=SellerAvailable(model.SellerType,model.SellerTypeId);
     if(String.IsNullOrEmpty(ErrorMessage)==false) {
         ModelState.AddModelError("Name",ErrorMessage);
     }
     if(ModelState.IsValid) {
         SellerType sellerType=AdminRepository.FindSellerType(model.SellerTypeId);
         if(sellerType==null) {
             sellerType=new SellerType();
             sellerType.CreatedBy=Authentication.CurrentUser.UserID;
             sellerType.CreatedDate=DateTime.Now;
         }
         sellerType.SellerType1=model.SellerType;
         sellerType.Enabled=model.Enabled;
         sellerType.EntityID=Authentication.CurrentEntity.EntityID;
         sellerType.LastUpdatedBy=Authentication.CurrentUser.UserID;
         sellerType.LastUpdatedDate=DateTime.Now;
         IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveSellerType(sellerType);
         if(errorInfo!=null) {
             resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo);
         } else {
             resultModel.Result="True||"+sellerType.SellerTypeID;
         }
     } else {
         foreach(var values in ModelState.Values.ToList()) {
             foreach(var err in values.Errors.ToList()) {
                 if(string.IsNullOrEmpty(err.ErrorMessage)==false) {
                     resultModel.Result+=err.ErrorMessage+"\n";
                 }
             }
         }
     }
     return View("Result",resultModel);
 }