Exemplo n.º 1
0
        public string AuthVendor(string vendorid)
        {
            string ret = "Could not Authorise vendor";

            try
            {
                var vendor = context.Vendors.Find(vendorid);
                if (vendor != null)
                {
                    vendor.Isauthorized = true;
                    context.Vendors.Update(vendor).Property(x => x.Id).IsModified = false;

                    context.SaveChanges();
                    ret = "Sucessfully authorized vendor " + vendor.Vendorid;
                }
                else
                {
                    ret = "vendor doesnt exist";
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(ret);
        }
Exemplo n.º 2
0
        public string AddServices(Vendorservices service)
        {
            var str = string.Empty;

            try
            {
                var userobj = (from u in context.Vendors
                               where u.Vendorid == service.Vendorid
                               select u).FirstOrDefault();

                var wish = (from w in context.Vendorservices
                            where w.Vendorid == service.Vendorid && w.Name == service.Name
                            select w).FirstOrDefault();
                if (userobj == null)
                {
                    return("enter valid data vendor doesnt exist");
                }
                else if (wish != null)
                {
                    return("Vendor has a same service alredy registered");
                }
                else
                {
                    context.Vendorservices.Add(service);
                    context.SaveChanges();
                    str = "sucessfully added service";
                }
            }
            catch (Exception e)
            {
                str = e.Message;
                throw (e);
            }
            return(str);
        }
Exemplo n.º 3
0
        public string DelPet(Pets pet)
        {
            var str = string.Empty;

            try
            {
                var dbpet = context.Pets.Find(pet.Petid);
                dbpet.Isdeleted = true;
                if (dbpet != null)
                {
                    context.Pets.Update(dbpet).Property(x => x.Id).IsModified = false;

                    context.SaveChanges();
                    str = "Sucessfully deleted";
                }
                else
                {
                    str = "Pet doesnt exist";
                }
            }
            catch (Exception e)
            {
                str = e.Message;
                throw e;
            };
            return(str);
        }
Exemplo n.º 4
0
        public string AddOtp(string phonenum, string otp)
        {
            var str = "could not add otp";

            try
            {
                var findobj = (from c in context.Otp
                               where c.Phoneno == phonenum
                               select c).FirstOrDefault();
                if (findobj == null)
                {
                    var obj = new Otp();
                    obj.Otpstring   = otp;
                    obj.Phoneno     = phonenum;
                    obj.CreatedDate = DateTime.Now;
                    context.Otp.Add(obj);
                    context.SaveChanges();
                    str = "sucessfully added otp";
                }
                else
                {
                    findobj.Otpstring   = otp;
                    findobj.CreatedDate = DateTime.Now;
                    using (var newContext = new StuffyCareContext())
                    {
                        newContext.Otp.Update(findobj);
                        newContext.SaveChanges();
                        str = "OTP updated sucessfully";
                    }
                }
            }
            catch (Exception e)
            {
                str = e.Message;
                throw e;
            }
            return(str);
        }
Exemplo n.º 5
0
        public string UpdateCart(Cart cart)
        {
            string status = "could not update try again";

            try
            {
                Cart carti = (from c in context.Cart
                              where c.Userid == cart.Userid && c.Itemid == cart.Itemid
                              select c).FirstOrDefault();
                carti.Quantity = cart.Quantity;
                using (var newContext = new StuffyCareContext())
                {
                    newContext.Cart.Update(carti);
                    newContext.SaveChanges();
                    status = "updated sucessfuly";
                }
            }
            catch (Exception e)
            {
                status = "exception occured in Dal";
                throw e;
            }
            return(status);
        }
Exemplo n.º 6
0
        public string UpdateServices(Vendorservices services)
        {
            string status = "could not update try again";

            try
            {
                Vendorservices carti = (from c in context.Vendorservices
                                        where c.Vendorid == services.Vendorid && c.Name == services.Name
                                        select c).FirstOrDefault();
                carti.Price = services.Price;
                using (var newContext = new StuffyCareContext())
                {
                    newContext.Vendorservices.Update(carti);
                    newContext.SaveChanges();
                    status = "updated sucessfuly";
                }
            }
            catch (Exception e)
            {
                status = "exception occured in Dal";
                throw e;
            }
            return(status);
        }