public PartialViewResult CreateDot()
        {
            var model = new CustomerDOTNumber();

            model.DOTStaus = "Create";
            return(PartialView("_CreateDot", model));
        }
        public PartialViewResult EditDotNumber(int Id, int ItemId)
        {
            CustomerDOTNumber customerData = new CustomerDOTNumber();

            customerData.ItemID = ItemId;
            return(PartialView("_CreateDot", customerData));
        }
 /// <summary>
 /// Create CustomerDOTNumber
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public CustomerDOTNumberDTO CreateCustomerDOTNumber(CustomerDOTNumber model)
 {
     if (IsActiveProfile)
     {
         var CDOTNumber = context.CustomerDOTNumbers.Where(o => o.DOTNumber == model.DOTNumber && o.CustomerID == model.CustomerID)
                          .Select(x => new CustomerDOTNumberDTO
         {
             ItemID     = x.ItemID,
             DOTNumber  = x.DOTNumber,
             DOTTag     = x.DOTTag,
             CustomerID = x.CustomerID,
             CreatedOn  = x.CreatedOn,
             ModifiedOn = x.ModifiedOn,
             IsActive   = x.IsActive,
             CreatedBy  = x.CreatedBy,
             ModifiedBy = x.ModifiedBy
         }).FirstOrDefault();
         if (CDOTNumber == null)
         {
             var customerDOT = new CustomerDOTNumber
             {
                 CustomerID = model.CustomerID,
                 DOTNumber  = CommonFunctions.Trimstring(model.DOTNumber),
                 DOTTag     = CommonFunctions.Trimstring(model.DOTTag),
                 IsActive   = true,
                 CreatedOn  = DateTime.Now,
                 CreatedBy  = model.CreatedBy,
                 ModifiedBy = model.CreatedBy,
                 ModifiedOn = DateTime.Now,
                 IsDelete   = false
             };
             context.CustomerDOTNumbers.Add(customerDOT);
             context.SaveChanges();
             var CustomerDOT = new CustomerDOTNumberDTO
             {
                 ItemID     = customerDOT.ItemID,
                 DOTNumber  = customerDOT.DOTNumber,
                 DOTTag     = customerDOT.DOTTag,
                 CustomerID = customerDOT.CustomerID,
                 CreatedOn  = customerDOT.CreatedOn,
                 ModifiedOn = customerDOT.ModifiedOn,
                 IsActive   = customerDOT.IsActive,
                 CreatedBy  = customerDOT.CreatedBy,
                 ModifiedBy = customerDOT.ModifiedBy
             };
             return(CustomerDOT);
         }
         else
         {
             return(CDOTNumber);
         }
     }
     return(null);
 }
 /// <summary>
 /// Update CustomerDOTNumber
 /// </summary>
 /// <param name="model"></param>
 /// <param name="RoleName"></param>
 /// <returns></returns>
 public CustomerDOTNumberDTO UpdateCustomerDOTNumber(CustomerDOTNumber model)
 {
     if (IsActiveProfile)
     {
         var CDOTNumber = context.CustomerDOTNumbers.Where(o => o.ItemID == model.ItemID && o.CustomerID == model.CustomerID).FirstOrDefault();
         if (CDOTNumber != null)
         {
             if (CDOTNumber.DOTNumber == model.DOTNumber)
             {
                 CDOTNumber.DOTTag     = CommonFunctions.Trimstring(model.DOTTag);
                 CDOTNumber.IsActive   = model.IsActive;
                 CDOTNumber.ModifiedOn = DateTime.Now;
                 CDOTNumber.ModifiedBy = model.ModifiedBy;
                 context.SaveChanges();
             }
             else
             {
                 //New Dot data Update
                 if (!context.CustomerDOTNumbers.Where(o => o.DOTNumber == model.DOTNumber).Any())
                 {
                     CDOTNumber.DOTNumber  = model.DOTNumber;
                     CDOTNumber.DOTTag     = CommonFunctions.Trimstring(model.DOTTag);
                     CDOTNumber.IsActive   = model.IsActive;
                     CDOTNumber.ModifiedOn = DateTime.Now;
                     CDOTNumber.ModifiedBy = model.ModifiedBy;
                     context.SaveChanges();
                 }
                 else
                 {
                     return(null);
                 }
             }
             var CustomerDOT = new CustomerDOTNumberDTO
             {
                 ItemID     = CDOTNumber.ItemID,
                 DOTNumber  = CDOTNumber.DOTNumber,
                 DOTTag     = CDOTNumber.DOTTag,
                 CustomerID = CDOTNumber.CustomerID,
                 CreatedOn  = CDOTNumber.CreatedOn,
                 ModifiedOn = CDOTNumber.ModifiedOn,
                 IsActive   = CDOTNumber.IsActive,
                 CreatedBy  = CDOTNumber.CreatedBy,
                 ModifiedBy = CDOTNumber.ModifiedBy
             };
             return(CustomerDOT);
         }
         else
         {
             return(null);
         }
     }
     return(null);
 }
        /// <summary>
        /// Delete CustomerDOTNumber
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool DeleteCustomerDOTNumber(CustomerDOTNumber model)
        {
            var CDOTNumber = context.CustomerDOTNumbers.Where(o => o.ItemID == model.ItemID).FirstOrDefault();

            if (CDOTNumber != null)
            {
                CDOTNumber.IsActive   = false;
                CDOTNumber.IsDelete   = true;
                CDOTNumber.ModifiedBy = model.ModifiedBy;
                CDOTNumber.ModifiedOn = DateTime.Now;
                context.SaveChanges();
                return(true);
            }
            return(false);
        }
        public StatusResult Delete(int itemID)
        {
            StatusResult c = new StatusResult();

            try
            {
                if (!ModelState.IsValid)
                {
                    c.Status = Status.BadRequest.ToString();
                    c.Result = BadRequest();
                    return(c);
                }
                if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin))
                {
                    CustomerDOTNumber model  = new CustomerDOTNumber();
                    CustomerDOT       cusDOT = new CustomerDOT();
                    model.ItemID     = itemID;
                    model.ModifiedBy = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
                    var CDOT = cusDOT.DeleteCustomerDOT(model);
                    if (CDOT == false)
                    {
                        c.Status = Status.Fail.ToString();
                        c.Result = "Customer DOTNumber object Not Found.";
                    }
                    else
                    {
                        c.Status = Status.Success.ToString();
                        c.Result = CDOT;
                    }
                    return(c);
                }
                else
                {
                    c.Status = Status.NoAccess.ToString();
                    c.Result = "No Access";
                    return(c);
                }
            }
            catch (Exception ex)
            {
                c.Status = Status.InternalServerError.ToString();
                c.Result = ex.InnerException;
                return(c);
            }
        }
        public StatusResult AddCustomerDOTNumber(CustomerDOTNumber model)
        {
            StatusResult c = new StatusResult();

            //try
            //{
            if (!ModelState.IsValid)
            {
                c.Status = Status.BadRequest.ToString();
                c.Result = BadRequest();
                return(c);
            }
            if (User.IsInRole(Roles.SuperAdmin) || User.IsInRole(Roles.PortalAdmin))
            {
                CustomerDOT cusDOT  = new CustomerDOT();
                var         custDOT = GetCustomerDOT(model.CustomerID, model.DOTNumber);
                if (custDOT.Status != Status.Fail.ToString())
                {
                    c.Status = Status.Fail.ToString();
                    c.Result = "Customer DOTNumber already exist.";
                }
                else
                {
                    model.CreatedBy = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
                    var CDOT = cusDOT.AddCustomerDOT(model);
                    c.Status = Status.Success.ToString();
                    c.Result = CDOT;
                }

                return(c);
            }
            else
            {
                c.Status = Status.NoAccess.ToString();
                c.Result = "No Access";
                return(c);
            }
            //}
            //catch (Exception ex)
            //{
            //    c.Status = Status.InternalServerError.ToString();
            //    c.Result = ex.InnerException;
            //    return c;
            //}
        }
        public async Task <ActionResult> AddCustomerDOTNumber(CustomerDOTNumber model)
        {
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userData.AccessToken);
            HttpResponseMessage responseMessage = await client.PostAsJsonAsync(_url + "CustomerDOT/Create", model);

            if (responseMessage.IsSuccessStatusCode)
            {
                var result = responseMessage.Content.ReadAsStringAsync().Result;
                statusResult = JsonConvert.DeserializeObject <StatusResult>(result);
                if (statusResult.Status.Equals(Status.Success.ToString()))
                {
                    return(Json(statusResult.Status, JsonRequestBehavior.AllowGet));
                }
                if (statusResult.Status.Equals(Status.Fail.ToString()))
                {
                    return(Json(statusResult.Result, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json("Error", JsonRequestBehavior.AllowGet));
        }
Esempio n. 9
0
        public bool DeleteCustomerDOT(CustomerDOTNumber model)
        {
            ICustomerDOTService customerDOT = new CustomerDOTService();

            return(customerDOT.DeleteCustomerDOTNumber(model));
        }
Esempio n. 10
0
        public CustomerDOTNumberDTO UpdateCustomerDOT(CustomerDOTNumber model)
        {
            ICustomerDOTService customerDOT = new CustomerDOTService(model.CustomerID);

            return(customerDOT.UpdateCustomerDOTNumber(model));
        }