Beispiel #1
0
        public ActionResult MyImage(int id, int img)
        {
            ViewBag.Pic = img;
            tblcustomer insp = db.tblcustomers.Find(id);

            return(View(insp));
        }
Beispiel #2
0
        //
        // GET: /ModuleMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (Request.Cookies["YourApLogin&"] != null)
            {
                string username = Request.Cookies["YourAppLogin"].Values["username"];
                string RoleID   = Request.Cookies["YourAppLogin"].Values["RoleID"];
                string UserID   = Request.Cookies["YourAppLogin"].Values["UserId"];
                Session["Username"] = username;
                Session["RoleID"]   = RoleID;
                Session["UserId"]   = UserID;
            }
            else if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            else
            {
                ViewBag.Logout = Session["Username"];
                ViewBag.roleid = Session["RoleID"];
                String Username = Session["Username"].ToString();
            }
            int         UserID1     = Convert.ToInt32(Session["UserID"].ToString());
            tblcustomer tblCustomer = db.tblcustomers.Find(id);

            tblCustomer.IsDeleted       = 1;
            tblCustomer.ModifiedBy      = UserID1;
            tblCustomer.ModifiedOn      = System.DateTime.Now;
            db.Entry(tblCustomer).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public HttpResponseMessage Post([FromBody] JObject customer_details)
        {
            try
            {
                // Check if a session already exists or if it's expired
                //if (HttpContext.Current.Session["Token"] == null)
                //    return Request.CreateResponse(HttpStatusCode.Unauthorized, new { Success = false, Message = "Session expired! Unable to authenticate user." });


                string name      = customer_details["name"].ToString().Trim();
                string mobile_no = customer_details["mobile_no"].ToString().Trim();
                int    salon_id  = int.Parse(customer_details["salon_id"].ToString());

                using (SalonDbEntities entities = new SalonDbEntities())
                {
                    // Check if the salon id exists
                    if (salon_id != 0 && !entities.tblsalons.Any(e => e.salon_id == salon_id))
                    {
                        return(Messages.GetInstance().HandleException("Retrieve failed! Salon with id = ", salon_id.ToString()));
                    }

                    // Validate customer mobile
                    if (!Utilities.getInstance().ValidateContactNumber(mobile_no))
                    {
                        return(Messages.GetInstance().ValidateFields("Customer", ActionType.INSERT, isContactNumber: true));
                    }

                    // Check if the customer mobile already exists in the particular salon.
                    if (entities.tblcustomers.Any(e => e.mobile_no.ToString().Trim() == mobile_no && e.salon_id == salon_id))
                    {
                        return(Messages.GetInstance().HandleException("Failed to create customer! A customer with the same mobile no exists in salon id = " + salon_id));
                    }

                    else
                    {
                        using (var transaction = entities.Database.BeginTransaction())
                        {
                            tblcustomer obj = new tblcustomer
                            {
                                name       = name,
                                mobile_no  = int.Parse(mobile_no),
                                salon_id   = salon_id,
                                login_time = DateTime.Now
                            };
                            entities.tblcustomers.Add(obj);
                            entities.SaveChanges();

                            Utilities.getInstance().UpdateChanges(entities, transaction, obj.customer_id.ToString(), typeof(tblcustomer).Name, ActionType.INSERT);

                            return(Messages.GetInstance().HandleRequest("Customer", ActionType.INSERT));
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(Messages.GetInstance().HandleException("An error occured! Failed to create customer."));
            }
        }
Beispiel #4
0
 public ActionResult edit(int id)
 {
     using (var db = new InvoiceEntities1())
     {
         tblcustomer cust = db.tblcustomers.Where(x => x.idcustomer == id).FirstOrDefault();
         return(View(cust));
     }
 }
Beispiel #5
0
 public ActionResult Create(tblcustomer tblcust, HttpPostedFileBase inputimg)
 {
     if (Request.Cookies["YourApLogin&"] != null)
     {
         string username = Request.Cookies["YourAppLogin"].Values["username"];
         string RoleID   = Request.Cookies["YourAppLogin"].Values["RoleID"];
         string UserID   = Request.Cookies["YourAppLogin"].Values["UserId"];
         Session["Username"] = username;
         Session["RoleID"]   = RoleID;
         Session["UserId"]   = UserID;
     }
     else if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
     {
         return(RedirectToAction("Login", "Login", null));
     }
     else
     {
         ViewBag.Logout = Session["Username"];
         ViewBag.roleid = Session["RoleID"];
         String Username = Session["Username"].ToString();
     }
     {//
         string filename = "";
         byte[] bytes;
         int    BytestoRead;
         int    numBytesRead;
         if (inputimg != null)
         {
             filename     = Path.GetFileName(inputimg.FileName);
             bytes        = new byte[inputimg.ContentLength];
             BytestoRead  = (int)inputimg.ContentLength;
             numBytesRead = 0;
             while (BytestoRead > 0)
             {
                 int n = inputimg.InputStream.Read(bytes, numBytesRead, BytestoRead);
                 if (n == 0)
                 {
                     break;
                 }
                 numBytesRead += n;
                 BytestoRead  -= n;
             }
             tblcust.Logo = bytes;
         }
         //
         int UserID1 = Convert.ToInt32(Session["UserID"].ToString());
         // Save was Start Now
         tblcust.CreatedBy = UserID1;
         tblcust.CreatedOn = System.DateTime.Now;
         tblcust.IsDeleted = 0;
         db.tblcustomers.Add(tblcust);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblcust));
 }
Beispiel #6
0
 public ActionResult delete(int id)
 {
     using (var db = new InvoiceEntities1())
     {
         tblcustomer cust = db.tblcustomers.FirstOrDefault(x => x.idcustomer == id);
         db.tblcustomers.Remove(cust);
         db.SaveChanges();
         return(RedirectToAction("Indexcust"));
     }
 }
Beispiel #7
0
 public ActionResult edit(tblcustomer obj)
 {
     using (var db = new InvoiceEntities1())
     {
         tblcustomer customer = db.tblcustomers.Where(x => x.idcustomer == obj.idcustomer).FirstOrDefault();
         customer.name     = obj.name;
         customer.mobileno = obj.mobileno;
         customer.emailid  = obj.emailid;
         customer.address  = obj.address;
         db.SaveChanges();
         return(RedirectToAction("Indexcust"));
     }
 }
Beispiel #8
0
        public ActionResult Edit(tblcustomer tblCustomer, HttpPostedFileBase inputimg)
        {
            if (Request.Cookies["YourApLogin&"] != null)
            {
                string username = Request.Cookies["YourAppLogin"].Values["username"];
                string RoleID   = Request.Cookies["YourAppLogin"].Values["RoleID"];
                string UserID   = Request.Cookies["YourAppLogin"].Values["UserId"];
                Session["Username"] = username;
                Session["RoleID"]   = RoleID;
                Session["UserId"]   = UserID;
            }
            else if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            else
            {
                ViewBag.Logout = Session["Username"];
                ViewBag.roleid = Session["RoleID"];
                String Username = Session["Username"].ToString();
            }
            int UserID1 = Convert.ToInt32(Session["UserID"].ToString());

            ViewBag.IsEmailEscalation = 0;
            //tblCustomer.Logo = inputimg;
            tblCustomer.ModifiedBy = UserID1;
            tblCustomer.ModifiedOn = System.DateTime.Now;
            {
                if (ModelState.IsValid)
                {
                    if (inputimg == null)
                    {
                        //byte b =Convert.ToByte(Session["logo"]);// img src
                        //byte[] imgarray = new byte[b];
                        //= (Session["logo"]).ToString();
                        //tblCustomer.Logo = Encoding.ASCII.GetBytes(a);
                        var a = Session["logo"] as byte[];
                        tblCustomer.Logo = a;
                    }
                    tblCustomer.IsDeleted       = 0;
                    db.Entry(tblCustomer).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(tblCustomer));
        }
Beispiel #9
0
 public ActionResult addcustomer(tblcustomer obj)
 {
     if (ModelState.IsValid)
     {
         int billno;
         InvoiceEntities1 db       = new InvoiceEntities1();
         tblcustomer      customer = new tblcustomer();
         customer.name     = obj.name;
         customer.mobileno = obj.mobileno;
         customer.emailid  = obj.emailid;
         customer.address  = obj.address;
         customer.billno   = db.tblcustomers.Count() + 1;
         db.tblcustomers.Add(customer);
         db.SaveChanges();
     }
     return(View(obj));
 }
Beispiel #10
0
        public HttpResponseMessage GetSelectedCustomer(int customer_id)
        {
            try
            {
                // Check if a session already exists or if it's expired
                //if (HttpContext.Current.Session["Token"] == null)
                //    return Request.CreateResponse(HttpStatusCode.Unauthorized, new { Success = false, Message = "Session expired! Unable to authenticate user." });


                using (SalonDbEntities entities = new SalonDbEntities())
                {
                    tblcustomer selectedCustomer = entities.tblcustomers.FirstOrDefault(e => e.customer_id == customer_id);
                    if (selectedCustomer != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, new
                        {
                            Success = true,
                            Message = "Customer retrieved successfully!",
                            Customer_details = new
                            {
                                selectedCustomer.customer_id,
                                selectedCustomer.salon_id,
                                selectedCustomer.name,
                                selectedCustomer.mobile_no,
                                selectedCustomer.login_time
                            }
                        }));
                    }

                    else
                    {
                        return(Messages.GetInstance().HandleException("Retrieve failed! Customer with id = ", customer_id.ToString()));
                    }
                }
            }
            catch (Exception)
            {
                return(Messages.GetInstance().HandleException("An error occured! Failed to retrieve customer details."));
            }
        }
Beispiel #11
0
        //
        // GET: /ModuleMaster/Edit/5

        public ActionResult Edit(int id)
        {
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];
            if (Request.Cookies["YourApLogin&"] != null)
            {
                string username = Request.Cookies["YourAppLogin"].Values["username"];
                string RoleID   = Request.Cookies["YourAppLogin"].Values["RoleID"];
                string UserID   = Request.Cookies["YourAppLogin"].Values["UserId"];
                Session["Username"] = username;
                Session["RoleID"]   = RoleID;
                Session["UserId"]   = UserID;
            }
            else if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            else
            {
                ViewBag.Logout = Session["Username"];
                ViewBag.roleid = Session["RoleID"];
                String Username = Session["Username"].ToString();
            }
            tblcustomer tblcust = db.tblcustomers.Find(id);

            Session["logo"] = tblcust.Logo;
            if (tblcust == null)
            {
                return(HttpNotFound());
            }
            return(View(tblcust));
        }