Example #1
0
        public bool UpdateOutlet(OutletModel model)
        {
            try
            {
                tblOutlet tb = entities.tblOutlets.Where(a => a.OutletId == model.OutletId).SingleOrDefault();
                tb.Active       = model.Active;
                tb.Address      = model.Address;
                tb.City         = model.City;
                tb.ContactA     = model.ContactA;
                tb.ContactB     = model.ContactB;
                tb.Email        = model.Email;
                tb.Name         = model.Name;
                tb.OutletId     = model.OutletId;
                tb.OutletType   = model.OutletType;
                tb.ServiceTaxNo = model.ServiceTaxNo;
                //tb.RegistrationDate = model.RegistrationDate;
                tb.TinNo = model.TinNo;

                tb.UserName = model.UserName;
                entities.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        //Get the details of a particular employee
        public OutletModel GetOutletData(string id)
        {
            OutletModel OutletModel = new OutletModel();

            using (SqlConnection con = new SqlConnection(conStr))
            {
                string     sqlQuery = "SELECT * FROM [dbo].[Outlets] WHERE Id LIKE '" + id + "'";
                SqlCommand cmd      = new SqlCommand(sqlQuery, con);

                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    OutletModel.ID         = rdr["Id"].ToString();
                    OutletModel.Name       = rdr["Name"].ToString();
                    OutletModel.Address    = rdr["Address"].ToString();
                    OutletModel.Company_Id = rdr["Company_Id"].ToString();
                    OutletModel.Group_Id   = rdr["Group_Id"].ToString();
                    OutletModel.Suspended  = Convert.ToBoolean(rdr["Suspended"]);
                    OutletModel.OutletCode = rdr["OutletCode"].ToString();
                }
            }
            return(OutletModel);
        }
        public ActionResult CreateOutlet(int id = 0)
        {
            if (id > 0)
            {
                var         data  = (from p in db.tblOutlets.Where(o => o.OutletId == id) select p).SingleOrDefault();
                OutletModel model = new OutletModel();
                model.OutletId         = data.OutletId;
                model.Active           = data.Active;
                model.Address          = data.Address;
                model.City             = data.City;
                model.ContactA         = data.ContactA;
                model.ContactB         = data.ContactB;
                model.Email            = data.Email;
                model.Name             = data.Name;
                model.RegistrationDate = data.RegistrationDate;
                model.TinNo            = data.TinNo;
                model.UserName         = data.UserName;
                model.ServiceTaxNo     = data.ServiceTaxNo;
                return(View(model));
            }

            else
            {
                return(View());
            }
        }
        public IEnumerable <OutletModel> GetAllOutlet(string id)
        {
            List <OutletModel> lstOutletModel = new List <OutletModel>();

            using (SqlConnection con = new SqlConnection(conStr))
            {
                SqlCommand cmd = new SqlCommand("spViewOutlet", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Company_Id", id);
                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    OutletModel OutletModel = new OutletModel();

                    OutletModel.ID         = rdr["Id"].ToString();
                    OutletModel.Name       = rdr["Name"].ToString();
                    OutletModel.Address    = rdr["Address"].ToString();
                    OutletModel.Company_Id = rdr["Company_Id"].ToString();
                    OutletModel.Group_Id   = rdr["Group_Id"].ToString();
                    OutletModel.Suspended  = Convert.ToBoolean(rdr["Suspended"]);
                    OutletModel.OutletCode = rdr["OutletCode"].ToString();
                    lstOutletModel.Add(OutletModel);
                }
                con.Close();
            }
            return(lstOutletModel);
        }
        public ActionResult Blocked()
        {
            var data = (from p in db.tblOutlets where p.OutletType.Equals("O") && p.Active == false select p).ToList();

            List <OutletModel> List = new List <OutletModel>();

            foreach (var item in data)
            {
                OutletModel model = new OutletModel();
                model.Active       = item.Active;
                model.Address      = item.Address;
                model.City         = item.City;
                model.ContactA     = item.ContactA;
                model.ContactB     = item.ContactB;
                model.Email        = item.Email;
                model.Name         = item.Name;
                model.OutletId     = item.OutletId;
                model.OutletType   = item.OutletType;
                model.ServiceTaxNo = item.ServiceTaxNo;
                //model.Password = item.Password;
                model.RegistrationDate = item.RegistrationDate;
                model.TinNo            = item.TinNo;
                model.UserName         = item.UserName;
                List.Add(model);
            }
            return(View(List));
        }
        public ActionResult Create()
        {
            OutletModel outlet = GetOutletUserAssociated();

            ViewBag.OperationTypes = GetOperationTypesByOutletId(outlet.Id);
            return(View());
        }
Example #7
0
        public ActionResult Create(OutletModel outlet)
        {
            var userId  = User.Identity.GetUserId();
            var company = _context.UserExtraInfo.FirstOrDefault(a => a.UserId == userId).Companies.FirstOrDefault();

            if (ModelState.IsValid)
            {
                outlet.DateTimeCreated = DateTime.UtcNow;
                outlet.DateTimeUpdated = DateTime.UtcNow;

                ReservationExclusionDayModel ReservExclDay = new ReservationExclusionDayModel();
                ReservExclDay.Outlet          = outlet;
                ReservExclDay.DateTimeCreated = DateTime.UtcNow;
                ReservExclDay.DateTimeUpdated = DateTime.UtcNow;
                _context.ReservationExclusionDay.Add(ReservExclDay);

                outlet.ReservationExclusionDay = ReservExclDay;
                outlet.CompanyId = company.Id;
                outlet.Company   = company;

                company.Outlets.Add(outlet);
                _context.Outlet.Add(outlet);
                _context.Entry(company).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();

                return(RedirectToAction("Index", "Company"));
            }

            return(View());
        }
        public int InsertOutlet(OutletModel outletModel)
        {
            int result = 0, storeCount = 0;

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                CommonRepository commonRepository = new CommonRepository(_ConnectionString);
                result = commonRepository.GetValidateUnique("Outlet", "OutletName", outletModel.OutletName, outletModel.Id.ToString());
                if (result > 0)
                {
                    return(-1);
                }

                int MaxId = commonRepository.GetMaxId("Outlet");

                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();

                var queryStoreCount = "select count(storeId) from Outlet where IsActive=1 And IsDeleted=0 And storeId=" + outletModel.StoreId;
                storeCount = con.QueryFirstOrDefault <int>(queryStoreCount, null, sqltrans);

                if (storeCount == 0)
                {
                    var query = "INSERT INTO Outlet" +
                                "(Id,StoreId, OutletName, OutletAddress1, OutletAddress2, OutletPhone, OutletEmail," +
                                " InvoiceHeader, InvoiceFooter, IsCollectTax, IsPreorPostPayment, IsActive, IsLock)" +
                                "VALUES " +
                                "(" + MaxId + ", @StoreId, @OutletName, @OutletAddress1, @OutletAddress2, @OutletPhone, @OutletEmail, " +
                                "@InvoiceHeader, @InvoiceFooter, @IsCollectTax, @IsPreorPostPayment, @IsActive, @IsLock); " +
                                " SELECT CAST(SCOPE_IDENTITY() as INT);";
                    result = con.Execute(query, outletModel, sqltrans, 0, System.Data.CommandType.Text);

                    if (result > 0)
                    {
                        sqltrans.Commit();

                        //CREATE ENTRY INTO FOODMENURATE
                        query = " INSERT INTO FOODMENURATE(Id, OutletId, FoodMenuId, SalesPrice, FoodVatTaxId, IsActive)  " +
                                " Select(select max(Id) from foodmenurate) + ROW_NUMBER() OVER(ORDER BY fm.id desc) AS Row# , " +
                                MaxId + ", FM.Id,FM.SalesPrice,FM.FoodVatTaxId,1 FROM FoodMenu FM WHERE isdeleted = 0 ";

                        result = con.Execute(query, outletModel, sqltrans, 0, System.Data.CommandType.Text);
                        string output = commonRepository.SyncTableStatus("Outlet");
                        output = commonRepository.SyncTableStatus("FOODMENURATE");
                    }
                    else
                    {
                        sqltrans.Rollback();
                    }
                }
                else
                {
                    result = -1;
                }
            }

            return(result);
        }
        public ActionResult Edit(int id)
        {
            OutletModel outlet = GetOutletUserAssociated();

            ViewBag.OperationTypes = GetOperationTypesByOutletId(outlet.Id);
            OperationHourSettingModel setting = GetOneOperationHour(id);

            return(View(setting));
        }
Example #10
0
 public IActionResult Create([Bind] OutletModel OutletModel)
 {
     OutletModel.Company_Id = TempData["CompanyId"].ToString();
     if (ModelState.IsValid)
     {
         objOutletModel.AddOutlet(OutletModel);
         return(RedirectToAction("Index", new { id = OutletModel.Company_Id }));
     }
     return(View(OutletModel));
 }
Example #11
0
        public ActionResult UnAssignOutlet(string userId)
        {
            var user = _context.UserExtraInfo.FirstOrDefault(a => a.UserId == userId);
            //Need to change if we allow 1 manager to manage multiple Outlets
            OutletModel outlet = _context.Outlet.Where(a => a.Managers.Any(b => b.UserId == userId)).FirstOrDefault();

            outlet.Managers.Remove(user);
            _context.Entry(outlet).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();
            return(RedirectToAction("Index", "Company"));
        }
Example #12
0
        public ActionResult DeleteSetting(int id)
        {
            OutletModel outlet  = GetOutletUserAssociated();
            var         setting = GetOneExclDate(id);

            outlet.ReservationExclusionDates.Remove(setting);
            _context.Entry(outlet).State = System.Data.Entity.EntityState.Modified;
            _context.ReservationExclusionDate.Remove(setting);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #13
0
        public ActionResult EditReservSetting(OutletModel outlet)
        {
            OutletModel oldOutlet = GetOneOutlet(outlet.Id);

            oldOutlet.ReservationAllowBefore = outlet.ReservationAllowBefore;
            oldOutlet.ReservationDuration    = outlet.ReservationDuration;
            outlet.DateTimeUpdated           = DateTime.UtcNow;

            _context.Entry(oldOutlet).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();
            return(RedirectToAction("Index", "Outlet"));
        }
Example #14
0
        public ActionResult DeleteOutlet(int id)
        {
            var         userId  = User.Identity.GetUserId();
            var         company = _context.UserExtraInfo.FirstOrDefault(a => a.UserId == userId).Companies.FirstOrDefault();
            OutletModel outlet  = GetOneOutlet(id);

            company.Outlets.Remove(outlet);
            _context.Entry(company).State = System.Data.Entity.EntityState.Modified;
            _context.Outlet.Remove(outlet);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Company"));
        }
        public ActionResult DeleteTable(long id)
        {
            OutletModel outlet = GetOutletUserAssociated();
            var         table  = GetOneTable(id);

            outlet.Tables.Remove(table);
            _context.Entry(outlet).State = System.Data.Entity.EntityState.Modified;
            _context.Table.Remove(table);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #16
0
        public IActionResult GetInventory(OutletModel outletModel)
        {
            IEnumerable <ProductModel> inventory = _productService.GetInventory(outletModel);

            if (inventory != null)
            {
                return(Ok(new { Response = inventory }));
            }
            else
            {
                return(Conflict(new { Response = CommonConstants.HttpResponseMessages.Exception }));
            }
        }
Example #17
0
        public IActionResult Update(OutletModel outlet)
        {
            List <OutletModel> data = _outletManagerService.UpdateOutlet(outlet);

            if (data.Count > 0)
            {
                return(new OkObjectResult(new { Response = data }));
            }
            else
            {
                return(new ConflictObjectResult(new { Response = "Error" }));
            }
        }
Example #18
0
        public IActionResult GetOutlet(int OutletId)
        {
            OutletModel data = _outletManagerService.GetOutlet(OutletId);

            if (data != null)
            {
                return(new OkObjectResult(new { Response = data }));
            }
            else
            {
                return(new ConflictObjectResult(new { Response = "Error" }));
            }
        }
Example #19
0
        public IActionResult Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            OutletModel OutletModel = objOutletModel.GetOutletData(id);

            if (OutletModel == null)
            {
                return(NotFound());
            }
            return(View(OutletModel));
        }
Example #20
0
 public IActionResult Edit(string id, [Bind] OutletModel OutletModel)
 {
     if (id != OutletModel.ID)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         OutletModel.Company_Id = TempData["CompanyId"].ToString();
         objOutletModel.UpdateOutlet(OutletModel);
         return(RedirectToAction("Index", new { id = OutletModel.Company_Id }));
     }
     return(View(OutletModel));
 }
        public ActionResult Edit(OutletModel model)
        {
            var data = user.UpdateOutlet(model);

            if (data == true)
            {
                TempData["Outlet"] = "Record Saved Successfully...";
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["Outlet"] = "UserName Already Exits !";
                return(RedirectToAction("Edit", new { OutletId = model.OutletId }));
            }
        }
Example #22
0
        public int UpdateOutlet(OutletModel outletModel)
        {
            int result = 0, storeCount = 0;

            using (SqlConnection con = new SqlConnection(_ConnectionString.Value.ConnectionString))
            {
                CommonRepository commonRepository = new CommonRepository(_ConnectionString);
                result = commonRepository.GetValidateUnique("Outlet", "OutletName", outletModel.OutletName, outletModel.Id.ToString());
                if (result > 0)
                {
                    return(-1);
                }

                con.Open();
                SqlTransaction sqltrans = con.BeginTransaction();

                if (outletModel.OriginalStoreId != outletModel.StoreId)
                {
                    var queryStoreCount = "select count(storeId) from Outlet where IsActive=1 And IsDeleted=0 And storeId=" + outletModel.StoreId;
                    storeCount = con.QueryFirstOrDefault <int>(queryStoreCount, null, sqltrans);
                }

                if (storeCount == 0)
                {
                    var query = "UPDATE Outlet SET " +
                                "StoreId=@StoreId, OutletName=@OutletName, OutletAddress1=@OutletAddress1, OutletAddress2=@OutletAddress2, " +
                                "OutletPhone=@OutletPhone, OutletEmail=@OutletEmail, InvoiceHeader=@InvoiceHeader, InvoiceFooter=@InvoiceFooter, " +
                                "IsCollectTax=@IsCollectTax, IsPreorPostPayment=@IsPreorPostPayment, IsActive=@IsActive, IsLock=@IsLock " +
                                "WHERE Id = @Id;";
                    result = con.Execute(query, outletModel, sqltrans, 0, System.Data.CommandType.Text);

                    if (result > 0)
                    {
                        sqltrans.Commit();
                        string output = commonRepository.SyncTableStatus("Outlet");
                    }
                    else
                    {
                        sqltrans.Rollback();
                    }
                }
                else
                {
                    result = -1;
                }
            }
            return(result);
        }
Example #23
0
        private string ValidationOutlet(OutletModel outletModel)
        {
            string ErrorString = string.Empty;

            if (string.IsNullOrEmpty(outletModel.OutletName))
            {
                ErrorString = _locService.GetLocalizedHtmlString("ValidAddOnesName");
                return(ErrorString);
            }
            //if (string.IsNullOrEmpty(outletModel.Price.ToString()) || outletModel.Price == 0)
            //{
            //    ErrorString = _locService.GetLocalizedHtmlString("ValidPrice");
            //    return ErrorString;
            //}

            return(ErrorString);
        }
Example #24
0
        public ActionResult Outlet(OutletModel outletModel, string submitButton)
        {
            int result = 0;

            outletModel.StoreList = _iDropDownService.GetStoreList();

            if (!ModelState.IsValid)
            {
                string errorString = this.ValidationOutlet(outletModel);
                if (!string.IsNullOrEmpty(errorString))
                {
                    ViewBag.Validate = errorString;
                    return(View(outletModel));
                }
            }

            if (outletModel.Id > 0)
            {
                result = _iOutletService.UpdateOutlet(outletModel);
                if (result == -1)
                {
                    ViewBag.Result      = _locService.GetLocalizedHtmlString("Store is already allocated to other outlet!");
                    ViewBag.UpdateError = _locService.GetLocalizedHtmlString("UpdateError");
                    return(View(outletModel));
                }
                else
                {
                    ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss");
                }
            }
            else
            {
                result = _iOutletService.InsertOutlet(outletModel);
                if (result == -1)
                {
                    ViewBag.Result    = _locService.GetLocalizedHtmlString("Store is already allocated to other outlet!");
                    ViewBag.SaveError = _locService.GetLocalizedHtmlString("SaveError");
                    return(View(outletModel));
                }
                else
                {
                    ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess");
                }
            }
            return(RedirectToAction("Index", "Outlet"));
        }
Example #25
0
        public IActionResult Add(OutletModel outlet)
        {
            List <OutletModel> data = _outletManagerService.AddOutlet(outlet);

            if (data != null && data.Count > 0)
            {
                return(new OkObjectResult(new { Response = data }));
            }
            else if (data == null)
            {
                return(new ConflictObjectResult(new { Response = "Store Already Exists" }));
            }
            else
            {
                return(new ConflictObjectResult(new { Response = "Error" }));
            }
        }
Example #26
0
        public ActionResult Index(long?id)
        {
            var outlet = new OutletModel();

            if (!id.HasValue)
            {
                outlet = GetOutletUserAssociated();
            }
            else
            {
                outlet = GetOneOutlet(id.Value);
            }
            ViewBag.Tables = _context.Table.Where(x => x.OutletId == id).ToList();
            OutletDashboardViewModel vm = new OutletDashboardViewModel();

            vm.Outlet = outlet;
            return(View(vm));
        }
        public void UpdateOutlet(OutletModel OutletModel)
        {
            using (SqlConnection con = new SqlConnection(conStr))
            {
                SqlCommand cmd = new SqlCommand("spUpdateOutlet", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Id", OutletModel.ID);
                cmd.Parameters.AddWithValue("@Name", OutletModel.Name);
                cmd.Parameters.AddWithValue("@OutletCode", OutletModel.OutletCode);
                cmd.Parameters.AddWithValue("@Suspended", OutletModel.Suspended);
                cmd.Parameters.AddWithValue("@Address", OutletModel.Address);

                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
        }
        //To Add new employee record
        public void AddOutlet(OutletModel OutletModel)
        {
            using (SqlConnection con = new SqlConnection(conStr))
            {
                SqlCommand cmd = new SqlCommand("spAddOutlet", con);
                cmd.CommandType = CommandType.StoredProcedure;
                Guid id = Guid.NewGuid();
                cmd.Parameters.AddWithValue("@Id", id.ToString());
                cmd.Parameters.AddWithValue("@Name", OutletModel.Name);
                cmd.Parameters.AddWithValue("@OutletCode", OutletModel.OutletCode);
                cmd.Parameters.AddWithValue("@Suspended", OutletModel.Suspended);
                cmd.Parameters.AddWithValue("@Company_Id", OutletModel.Company_Id);
                cmd.Parameters.AddWithValue("@Address", OutletModel.Address);

                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
        }
Example #29
0
 public ActionResult Edit(OutletModel outlet)
 {
     if (ModelState.IsValid)
     {
         OutletModel oldOutlet = GetOneOutlet(outlet.Id);
         oldOutlet.DateTimeUpdated       = DateTime.UtcNow;
         oldOutlet.Name                  = outlet.Name;
         oldOutlet.Location              = outlet.Location;
         oldOutlet.Address               = outlet.Address;
         oldOutlet.PhoneNum              = outlet.PhoneNum;
         oldOutlet.ContactPersonPhoneNum = outlet.ContactPersonPhoneNum;
         oldOutlet.Description           = outlet.Description;
         oldOutlet.isActive              = outlet.isActive;
         _context.Entry(outlet).State    = System.Data.Entity.EntityState.Modified;
         _context.SaveChanges();
         return(Redirect(Request.UrlReferrer.ToString()));
     }
     return(View(outlet));
 }
Example #30
0
        public OutletModel EditOutlet(int OutletId)
        {
            OutletModel model = new OutletModel();
            var         data  = entities.tblOutlets.Where(a => a.OutletId == OutletId).SingleOrDefault();

            model.Active           = data.Active;
            model.Address          = data.Address;
            model.City             = data.City;
            model.ContactA         = data.ContactA;
            model.ContactB         = data.ContactB;
            model.Email            = data.Email;
            model.Name             = data.Name;
            model.OutletId         = data.OutletId;
            model.OutletType       = data.OutletType;
            model.RegistrationDate = data.RegistrationDate;
            model.TinNo            = data.TinNo;
            model.UserName         = data.UserName;
            model.ServiceTaxNo     = data.ServiceTaxNo;
            return(model);
        }