예제 #1
0
        public string DeleteCustomerCard(int Id)
        {
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    var enditedCustomerCardDiscountper = new LMS_Datas.CustomerCard
                    {
                        CustomerCardId = Id,
                        Activate       = false
                    };
                    entity.CustomerCards.Attach(enditedCustomerCardDiscountper);
                    entity.SaveChanges();
                    msg = "Delete Successfully";
                }
                else
                {
                    msg = "Validation data not successfully";
                }
                return(msg);
            }
            catch (Exception e1)
            {
                msg = "Validation data not successfully";
                return(msg);
            }
            return(msg);
        }
예제 #2
0
        public ActionResult Index(CustomerCard model, FormCollection form)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string customerName = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.Name).First().ToString();
                    string AssignNo     = form["Card Code"].ToString();
                    string mobileNumber = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.MobileNo).First().ToString();
                    mobileNumber = mobileNumber.Replace("(", String.Empty);
                    mobileNumber = mobileNumber.Replace(")", String.Empty);
                    mobileNumber = mobileNumber.Replace("-", String.Empty);
                    mobileNumber = mobileNumber.Replace(" ", String.Empty);
                    string cardname = (from e in entity.Card1 where e.CardId == model.Cardid select e.CardName).First().ToString();
                    string mailId   = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.EmailId).First().ToString();
                    using (var context = new LoyaltyManagementSystemEntities())
                    {
                        var addCustomerVoucher = new LMS_Datas.CustomerCard()
                        {
                            CustomerId  = model.CustomerId,
                            Cardid      = model.Cardid,
                            referenceNo = AssignNo,
                            Activate    = true
                        };
                        context.CustomerCards.Add(addCustomerVoucher);

                        //context.ClientDetails.Add(clientDetails);
                        //etc add your other classes
                        context.SaveChanges();
                    }
                    ViewBag.CustomerId = new SelectList(entity.Customers.Where(models => models.Active == true), "CustomerId", "Name");
                    ViewBag.CardId     = new SelectList(entity.Card1.Where(models => models.Activate == true), "CardId", "CardName");
                    ViewBag.alert      = "Success";
                    builder.Append("Hello " + customerName + ",").AppendLine();
                    builder.Append("Voucher " + cardname + " is assigned to you. Use Reference No. " + AssignNo + " for further references.").AppendLine();
                    builder.Append("Thanks");
                    //sms.send(mobileNumber, builder);
                    sms.send("8285601519", builder);
                    Mail.send(builder, "*****@*****.**", "*****@*****.**", "Voucher Assigned");
                }
            }
            catch (Exception e1)
            {
                ViewBag.alert = "Error";
            }
            return(View());
        }
예제 #3
0
        public string EditCustomerCard(CustomerCard Model, FormCollection form)
        {
            string CustomerName = form["CustomerName"].ToString();
            string CardName     = form["CardName"].ToString();
            string referenceNo  = form["ReferenceNo"].ToString();
            int    id           = Convert.ToInt16(form["id"].ToString());
            int    customerId   = (from customer in entity.Customers where customer.Name == CustomerName select customer.CustomerId).FirstOrDefault();
            int    CardId       = (from card in entity.Card1 where card.CardName == CardName select card.CardId).FirstOrDefault();
            string msgClient    = null;

            if (customerId != 0 && CardId != 0)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        var enditedCustomerCardValue = new LMS_Datas.CustomerCard
                        {
                            CustomerId     = customerId,
                            Cardid         = CardId,
                            referenceNo    = referenceNo,
                            CustomerCardId = id
                        };

                        entity.CustomerCards.Attach(enditedCustomerCardValue);
                        entity.Entry(enditedCustomerCardValue).State = EntityState.Modified;
                        entity.SaveChanges();
                        msgClient = "Saved Successfully";
                    }
                    else
                    {
                        msgClient = "Validation data not successfully";
                    }
                }
                catch (Exception ex)
                {
                    msgClient = "Error in Retriving Data";
                }
            }
            else
            {
                msgClient = "Error in Retriving Data";
            }
            return(msgClient);
        }