Exemplo n.º 1
0
 public ActionResult ChangeSalesPerson(string[] CustomerEmail, string SalesPersonID)
 {
     try
     {
         var    DB            = new BG_DBEntities();
         string CurrentUserID = DB.AspNetUsers.FirstOrDefault(x => x.Email == User.Identity.Name).Id;
         if (CustomerEmail.Count() > 0)
         {
             foreach (var i in CustomerEmail)
             {
                 var Old = DB.AssignSalesPersonMsts.Where(x => x.CustomerID == i).ToList();
                 if (Old.Count() > 0)
                 {
                     Old.ForEach(x => x.Active = false);
                     DB.SaveChanges();
                 }
                 var obj = new AssignSalesPersonMst
                 {
                     Active        = true,
                     CreatedDate   = DateTime.Now,
                     CreatedBy     = CurrentUserID,
                     SalesPersonID = SalesPersonID,
                     CustomerID    = i
                 };
                 DB.AssignSalesPersonMsts.Add(obj);
                 DB.SaveChanges();
             }
         }
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 2
0
 public ActionResult AssignSalesPersons(string CustomerEmail, string SalesPersonID)
 {
     try
     {
         var    DB            = new BG_DBEntities();
         string CurrentUserID = DB.AspNetUsers.FirstOrDefault(x => x.Email == User.Identity.Name).Id;
         string CustomerID    = DB.AspNetUsers.FirstOrDefault(x => x.Email == CustomerEmail).Id;
         var    obj           = new AssignSalesPersonMst
         {
             Active        = true,
             CreatedDate   = DateTime.Now,
             CreatedBy     = CurrentUserID,
             SalesPersonID = SalesPersonID,
             CustomerID    = CustomerID
         };
         DB.AssignSalesPersonMsts.Add(obj);
         DB.SaveChanges();
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }