Пример #1
0
        public async Task <IActionResult> PutServicesType([FromRoute] int id, [FromBody] ServicesType servicesType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != servicesType.Id)
            {
                return(BadRequest());
            }

            servicesType.ModifiedDate   = DateTime.Now;
            servicesType.LastModifiedBy = "leila";

            _context.Entry(servicesType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ServicesTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,LastModifiedBy,CreatedDate,ModifiedDate,Name")] ServicesType servicesType)
        {
            if (id != servicesType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(servicesType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServicesTypeExists(servicesType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicesType));
        }
 // GET: Manage/ServicesTypes/Delete/5
 public ActionResult Delete(int? id)
 {
     ServicesType servicesType = db.ServicesTypes.Find(id);
     db.ServicesTypes.Remove(servicesType);
     db.SaveChanges();
     return RedirectToAction("Manage-51", "Manage");
 }
Пример #4
0
 public IActionResult AddServicesType([FromBody] ServicesType ServicesType)
 {
     if (ServicesType != null)
     {
         _UnitOfwork.entity.Insert(ServicesType);
     }
     return(Ok());
 }
Пример #5
0
 public IncidentCategoriesViewModel()
 {
     BusinessFunctionTypes    = new List <BusinessFunctionType>();
     ServicesTypes            = new ServicesType();
     CategoryTypes            = new CategoryType();
     SR_BusinessFunctionTypes = new SR_BusinessFunction();
     SR_ServiceTypes          = new SR_ServiceType();
     SR_CategoryTypes         = new SR_CategoryType();
 }
Пример #6
0
        public void UpdateServicesType(int id, ServicesType ServicesType)
        {
            var e = _TicketsContext.ServicesType.Where(m => m.ServiceTypeID == id).FirstOrDefault();

            if (e != null)
            {
                e.ServiceTypeName = ServicesType.ServiceTypeName;
                _TicketsContext.SaveChanges();
            }
        }
 public ActionResult Edit([Bind(Include = "ServicesTypeID,ServicesTypeName,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify")] ServicesType servicesType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicesType).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Manage-51", "Manage");
     }
     return View(servicesType);
 }
Пример #8
0
        public async Task <IActionResult> Create([Bind("Id,LastModifiedBy,CreatedDate,ModifiedDate,Name")] ServicesType servicesType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(servicesType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicesType));
        }
Пример #9
0
        public async Task <IActionResult> PostServicesType([FromBody] ServicesType servicesType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ServicesType.Add(servicesType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetServicesType", new { id = servicesType.Id }, servicesType));
        }
 // GET: Manage/ServicesTypes/Edit/5
 public ActionResult Edit(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     ServicesType servicesType = db.ServicesTypes.Find(id);
     if (servicesType == null)
     {
         return HttpNotFound();
     }
     return View(servicesType);
 }
Пример #11
0
        public async Task <IActionResult> PostServicesType([FromBody] ServicesType servicesType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            servicesType.CreatedDate    = DateTime.Now;
            servicesType.ModifiedDate   = DateTime.Now;
            servicesType.LastModifiedBy = "leila";

            _context.ServicesType.Add(servicesType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetServicesType", new { id = servicesType.Id }, servicesType));
        }
Пример #12
0
        public async Task <IActionResult> Create(int giftCertNo, [Bind("Id,LastModifiedBy,CreatedDate,ModifiedDate,Name,Active,GiftCertNo")] ServicesType servicesType)
        {
            if (ModelState.IsValid)
            {
                servicesType.GiftCertNo     = giftCertNo;
                servicesType.LastModifiedBy = "leila";
                servicesType.CreatedDate    = DateTime.Now;
                servicesType.ModifiedDate   = DateTime.Now;
                servicesType.Active         = true;
                _context.Add(servicesType);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Edit", "GiftCert", new { id = giftCertNo }));
            }
            return(View(servicesType));
        }
        internal void AddServiceTypes()
        {
            var dbContext = new CorierServiceContext();

            var serviceType1 = new ServicesType()
            {
                ServiceType = "Regular"
            };
            var serviceType2 = new ServicesType {
                ServiceType = "Express"
            };
            var serviceType3 = new ServicesType {
                ServiceType = "Economy"
            };

            dbContext.ServicesTypes.Add(serviceType1);
            dbContext.ServicesTypes.Add(serviceType2);
            dbContext.ServicesTypes.Add(serviceType3);

            dbContext.SaveChanges();
        }
Пример #14
0
        public ValidationResponse BulkCopy(string filePath)
        {
            var response = new ValidationResponse();

            response = ValidateExcelFile(filePath);

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
            string connectionstring = Configuration["ConnectionStrings:ProductionConnection"];

            //  var filePath = @"D:/GcDetails.xlsx";
            FileInfo file = new FileInfo(filePath);

            using (ExcelPackage package = new ExcelPackage(file))
            {
                StringBuilder  sb        = new StringBuilder();
                ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                int            rowCount  = worksheet.Dimension.Rows;
                int            ColCount  = worksheet.Dimension.Columns;

                var           rawText = string.Empty;
                List <string> records = new List <string>();

                //validate column headers
                response = ValidateColumnHeaders(response, ColCount, worksheet);

                for (int row = 2; row <= rowCount; row++)
                {
                    for (int col = 1; col <= ColCount; col++)
                    {
                        if (col == 1 && worksheet.Cells[row, col].Value == null)
                        {
                            break;
                        }

                        if (worksheet.Cells[row, col].Value != null)
                        {
                            rawText += worksheet.Cells[row, col].Value.ToString() + "|";
                        }
                        else
                        {
                            rawText += "|";
                        }
                    }
                    rawText += "\n";
                }

                records = new List <string>(rawText.Split('\n'));

                var gcList = new List <GiftCertDto>();

                for (int i = 0; i < records.Count; i++)
                {
                    var record     = records[i];
                    var lineNumber = i + 2;

                    if (string.IsNullOrEmpty(record))
                    {
                        break;
                    }

                    var gc          = new GiftCertDto();
                    var gcTypeItems = new List <string> {
                        "regular gc", "promotional gc", "corporate gc"
                    };
                    string[] textpart = record.Split('|');

                    if (textpart[0] != string.Empty && IsCharDigit(textpart[0].ToString()))
                    {
                        gc.GiftCertNo = Convert.ToInt32(textpart[0]);
                    }
                    if (gcTypeItems.Contains(textpart[1].ToLower().Trim()))
                    {
                        gc.GcTypeName = textpart[1].Trim();
                    }
                    if (textpart[2] != string.Empty && IsCharDigit(textpart[2].ToString()))
                    {
                        gc.Value = Convert.ToDecimal(textpart[2]);
                    }
                    if (textpart[3] != string.Empty && IsValidDateFormat(textpart[3]))
                    {
                        gc.IssuanceDate = Convert.ToDateTime(textpart[3]);
                    }
                    gc.Note        = textpart[5];
                    gc.DtiPermitNo = textpart[6];
                    if (textpart[7] != string.Empty && IsValidDateFormat(textpart[7]))
                    {
                        gc.ExpirationDate = Convert.ToDateTime(textpart[7]);
                    }

                    var      outletList    = new List <OutletDto>();
                    string[] outletRecords = textpart[8].Split(';');

                    foreach (string outletRecord in outletRecords)
                    {
                        var outlet = new OutletDto();
                        outlet.Name = outletRecord;
                        outletList.Add(outlet);
                    }

                    var      servicesList    = new List <ServicesTypeDto>();
                    string[] servicesRecords = textpart[4].Split(';');

                    foreach (string servicesRecord in servicesRecords)
                    {
                        var servicesType = new ServicesTypeDto();
                        servicesType.Name = ServiceSetVar(servicesRecord, gc, outletList);
                        servicesList.Add(servicesType);
                    }

                    //Outlets - Promotional GC:
                    var outletItems = new List <string> {
                        "café marco", "wellness zone spa", "rooms"
                    };
                    if (outletList.Where(o => !string.IsNullOrEmpty(o.Name)).Select(o => o.Name.ToLower().Trim()).Except(outletItems).Any())
                    {
                        response.ErrorMsg.Add(String.Format("Line {0}: Promotional GC should contains only Café Marco, Wellness Zone Spa and Rooms.", lineNumber));
                    }

                    gc.Services = servicesList;
                    gc.Outlets  = outletList;

                    gcList.Add(gc);
                }

                //validate sequential gcno
                var isSequential = IsSequential(gcList.Select(m => m.GiftCertNo).ToArray());
                if (!isSequential)
                {
                    response.ErrorMsg.Add("Column A: GC Number should be sequenced.");
                }

                if (response.ErrorMsg.Count > 0)
                {
                    _toastNotification.AddErrorToastMessage("Your Import has failed.");
                    return(response);
                }

                //sql entity
                var giftCerts = new List <GiftCert>();
                var gcOutlets = new List <GcOutlet>();
                var services  = new List <ServicesType>();

                foreach (var gc in gcList)
                {
                    var giftCert = new GiftCert();

                    if (gc.GcTypeName.Replace(" ", "").ToLower() == GcTypeOptions.RegularGC.ToString().ToLower())
                    {
                        giftCert.GcTypeId = (int)GcTypeOptions.RegularGC;
                    }
                    if (gc.GcTypeName.Replace(" ", "").ToLower() == GcTypeOptions.PromotionalGC.ToString().ToLower())
                    {
                        giftCert.GcTypeId = (int)GcTypeOptions.PromotionalGC;
                    }
                    if (gc.GcTypeName.Replace(" ", "").ToLower() == GcTypeOptions.CorporateGC.ToString().ToLower())
                    {
                        giftCert.GcTypeId = (int)GcTypeOptions.CorporateGC;
                    }

                    giftCert.Value          = gc.Value;
                    giftCert.DtiPermitNo    = gc.DtiPermitNo;
                    giftCert.ExpirationDate = gc.ExpirationDate;
                    giftCert.IssuanceDate   = gc.IssuanceDate;
                    giftCert.QrCode         = Guid.NewGuid().ToString();
                    giftCert.GiftCertNo     = gc.GiftCertNo;
                    giftCert.Note           = gc.Note;

                    giftCert.LastModifiedBy = "leila";
                    giftCert.CreatedDate    = DateTime.Now;
                    giftCert.ModifiedDate   = DateTime.Now;

                    giftCerts.Add(giftCert);

                    //gcoutlet
                    foreach (var outlet in gc.Outlets)
                    {
                        if (string.IsNullOrEmpty(outlet.Name))
                        {
                            break;
                        }

                        var gcOutlet = new GcOutlet();
                        if (outlet.Name.Replace(" ", "") == OutletOptions.CaféMarco.ToString())
                        {
                            gcOutlet.OutletId = (int)OutletOptions.CaféMarco;
                        }
                        if (outlet.Name.Replace(" ", "") == OutletOptions.ElViento.ToString())
                        {
                            gcOutlet.OutletId = (int)OutletOptions.ElViento;
                        }
                        if (outlet.Name.Replace(" ", "") == OutletOptions.LobbyLounge.ToString())
                        {
                            gcOutlet.OutletId = (int)OutletOptions.LobbyLounge;
                        }

                        if (outlet.Name.Replace(" ", "") == OutletOptions.WellnessZoneSpa.ToString())
                        {
                            gcOutlet.OutletId = (int)OutletOptions.WellnessZoneSpa;
                        }
                        if (outlet.Name.Replace(" ", "") == OutletOptions.Rooms.ToString())
                        {
                            gcOutlet.OutletId = (int)OutletOptions.Rooms;
                        }
                        if (outlet.Name.Replace(" ", "") == OutletOptions.BluBarAndGrill.ToString())
                        {
                            gcOutlet.OutletId = (int)OutletOptions.BluBarAndGrill;
                        }

                        gcOutlet.GiftCertNo = gc.GiftCertNo;
                        gcOutlets.Add(gcOutlet);
                    }

                    //services
                    foreach (var service in gc.Services)
                    {
                        if (string.IsNullOrEmpty(service.Name))
                        {
                            break;
                        }

                        var servicesType = new ServicesType();

                        servicesType.GiftCertNo     = gc.GiftCertNo;
                        servicesType.Name           = service.Name;
                        servicesType.Active         = true;
                        servicesType.LastModifiedBy = "leila";
                        servicesType.CreatedDate    = DateTime.Now;
                        servicesType.ModifiedDate   = DateTime.Now;

                        services.Add(servicesType);
                    }
                }

                var gcParameters = new[]
                {
                    nameof(GiftCert.GcTypeId),
                    nameof(GiftCert.Value),
                    nameof(GiftCert.IssuanceDate),
                    nameof(GiftCert.DtiPermitNo),
                    nameof(GiftCert.ExpirationDate),
                    nameof(GiftCert.LastModifiedBy),
                    nameof(GiftCert.CreatedDate),
                    nameof(GiftCert.ModifiedDate),
                    nameof(GiftCert.QrCode),
                    nameof(GiftCert.Note),
                    nameof(GiftCert.Status),
                    nameof(GiftCert.GiftCertNo)
                };

                var gcOutletParameters = new[]
                {
                    nameof(GcOutlet.Id),
                    nameof(GcOutlet.OutletId),
                    nameof(GcOutlet.GiftCertNo)
                };

                var serviceTypeParameters = new[]
                {
                    nameof(ServicesType.Id),
                    nameof(ServicesType.LastModifiedBy),
                    nameof(ServicesType.CreatedDate),
                    nameof(ServicesType.ModifiedDate),
                    nameof(ServicesType.Name),
                    nameof(ServicesType.Active),
                    nameof(ServicesType.GiftCertNo)
                };


                using (var sqlcopy = new SqlBulkCopy(connectionstring, SqlBulkCopyOptions.Default))
                {
                    sqlcopy.BatchSize = 500;

                    sqlcopy.DestinationTableName = "[GiftCert]";
                    using (var reader = ObjectReader.Create(giftCerts, gcParameters))
                    {
                        sqlcopy.WriteToServer(reader);
                    }

                    sqlcopy.DestinationTableName = "[GcOutlet]";
                    using (var reader = ObjectReader.Create(gcOutlets, gcOutletParameters))
                    {
                        sqlcopy.WriteToServer(reader);
                    }

                    sqlcopy.DestinationTableName = "[ServicesType]";
                    using (var reader = ObjectReader.Create(services, serviceTypeParameters))
                    {
                        sqlcopy.WriteToServer(reader);
                    }
                }
            }
            return(response);
        }
Пример #15
0
 public IActionResult UpdateServicesType(int id, [FromBody] ServicesType ServicesType)
 {
     _UnitOfwork.entity.UpdateServicesType(id, ServicesType);
     return(Ok(ServicesType));
 }
Пример #16
0
        public ValidationResponse BulkCopy(string filePath)
        {
            var response = new ValidationResponse();

            response = ValidateExcelFile(filePath);

            if (response.IsValid)
            {
                // TODO: Extract this to a service class
                // load from excel

                var builder = new ConfigurationBuilder()
                              .SetBasePath(Directory.GetCurrentDirectory())
                              .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                              .AddEnvironmentVariables();

                builder.AddEnvironmentVariables();
                Configuration = builder.Build();
                string connectionstring = Configuration["ConnectionStrings:DefaultConnection"];

                //  var filePath = @"D:/GcDetails.xlsx";
                FileInfo file = new FileInfo(filePath);

                using (ExcelPackage package = new ExcelPackage(file))
                {
                    StringBuilder  sb        = new StringBuilder();
                    ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                    int            rowCount  = worksheet.Dimension.Rows;
                    int            ColCount  = worksheet.Dimension.Columns;

                    var           rawText = string.Empty;
                    List <string> records = new List <string>();

                    for (int row = 2; row <= rowCount; row++)
                    {
                        for (int col = 1; col <= ColCount; col++)
                        {
                            if (col == 1 && worksheet.Cells[row, col].Value == null)
                            {
                                break;
                            }

                            if (worksheet.Cells[row, col].Value != null)
                            {
                                rawText += worksheet.Cells[row, col].Value.ToString() + "|";
                            }
                            else
                            {
                                rawText += "|";
                            }
                        }
                        rawText += "\n";
                    }

                    records = new List <string>(rawText.Split('\n'));

                    var gcList = new List <GiftCertDto>();

                    foreach (string record in records)
                    {
                        if (string.IsNullOrEmpty(record))
                        {
                            break;
                        }

                        var gc = new GiftCertDto();

                        string[] textpart = record.Split('|');

                        if (textpart[0] != string.Empty)
                        {
                            gc.GiftCertNo = Convert.ToInt32(textpart[0]);
                        }
                        gc.GcTypeName = textpart[1];
                        if (textpart[2] != string.Empty)
                        {
                            gc.Value = Convert.ToDecimal(textpart[2]);
                        }
                        gc.Note        = textpart[4];
                        gc.DtiPermitNo = textpart[5];
                        if (textpart[6] != string.Empty)
                        {
                            gc.ExpirationDate = Convert.ToDateTime(textpart[6]);
                        }

                        var      servicesList    = new List <ServicesTypeDto>();
                        string[] servicesRecords = textpart[3].Split(';');

                        foreach (string servicesRecord in servicesRecords)
                        {
                            var servicesType = new ServicesTypeDto();
                            servicesType.Name = servicesRecord;
                            servicesList.Add(servicesType);
                        }

                        var      outletList    = new List <OutletDto>();
                        string[] outletRecords = textpart[7].Split(';');

                        foreach (string outletRecord in outletRecords)
                        {
                            var outlet = new OutletDto();
                            outlet.Name = outletRecord;
                            outletList.Add(outlet);
                        }

                        gc.Services = servicesList;
                        gc.Outlets  = outletList;


                        gcList.Add(gc);
                    }

                    //sql entity
                    var giftCerts = new List <GiftCert>();
                    var gcOutlets = new List <GcOutlet>();
                    var services  = new List <ServicesType>();

                    foreach (var gc in gcList)
                    {
                        var giftCert = new GiftCert();

                        if (gc.GcTypeName.Replace(" ", "") == GcTypeOptions.RegularGC.ToString())
                        {
                            giftCert.GcTypeId = (int)GcTypeOptions.RegularGC;
                        }
                        if (gc.GcTypeName.Replace(" ", "") == GcTypeOptions.PromotionalGC.ToString())
                        {
                            giftCert.GcTypeId = (int)GcTypeOptions.PromotionalGC;
                        }
                        if (gc.GcTypeName.Replace(" ", "") == GcTypeOptions.CorporateGC.ToString())
                        {
                            giftCert.GcTypeId = (int)GcTypeOptions.CorporateGC;
                        }

                        giftCert.Value          = gc.Value;
                        giftCert.DtiPermitNo    = gc.DtiPermitNo;
                        giftCert.ExpirationDate = gc.ExpirationDate;
                        giftCert.QrCode         = Guid.NewGuid().ToString();
                        giftCert.GiftCertNo     = gc.GiftCertNo;
                        giftCert.Note           = gc.Note;

                        giftCert.LastModifiedBy = "leila";
                        giftCert.CreatedDate    = DateTime.Now;
                        giftCert.ModifiedDate   = DateTime.Now;

                        giftCerts.Add(giftCert);

                        //gcoutlet
                        foreach (var outlet in gc.Outlets)
                        {
                            if (string.IsNullOrEmpty(outlet.Name))
                            {
                                break;
                            }

                            var gcOutlet = new GcOutlet();
                            if (outlet.Name.Replace(" ", "") == OutletOptions.CaféMarco.ToString())
                            {
                                gcOutlet.OutletId = (int)OutletOptions.CaféMarco;
                            }
                            if (outlet.Name.Replace(" ", "") == OutletOptions.ElViento.ToString())
                            {
                                gcOutlet.OutletId = (int)OutletOptions.ElViento;
                            }
                            if (outlet.Name.Replace(" ", "") == OutletOptions.LobbyLounge.ToString())
                            {
                                gcOutlet.OutletId = (int)OutletOptions.LobbyLounge;
                            }

                            gcOutlet.GiftCertNo = gc.GiftCertNo;
                            gcOutlets.Add(gcOutlet);
                        }

                        //services
                        foreach (var service in gc.Services)
                        {
                            if (string.IsNullOrEmpty(service.Name))
                            {
                                break;
                            }

                            var servicesType = new ServicesType();

                            servicesType.GiftCertNo     = gc.GiftCertNo;
                            servicesType.Name           = service.Name;
                            servicesType.Active         = true;
                            servicesType.LastModifiedBy = "leila";
                            servicesType.CreatedDate    = DateTime.Now;
                            servicesType.ModifiedDate   = DateTime.Now;

                            services.Add(servicesType);
                        }
                    }

                    var gcParameters = new[]
                    {
                        nameof(GiftCert.GcTypeId),
                        nameof(GiftCert.Value),
                        nameof(GiftCert.IssuanceDate),
                        nameof(GiftCert.DtiPermitNo),
                        nameof(GiftCert.ExpirationDate),
                        nameof(GiftCert.LastModifiedBy),
                        nameof(GiftCert.CreatedDate),
                        nameof(GiftCert.ModifiedDate),
                        nameof(GiftCert.QrCode),
                        nameof(GiftCert.Note),
                        nameof(GiftCert.Status),
                        nameof(GiftCert.GiftCertNo)
                    };

                    var gcOutletParameters = new[]
                    {
                        nameof(GcOutlet.Id),
                        nameof(GcOutlet.OutletId),
                        nameof(GcOutlet.GiftCertNo)
                    };

                    var serviceTypeParameters = new[]
                    {
                        nameof(ServicesType.Id),
                        nameof(ServicesType.LastModifiedBy),
                        nameof(ServicesType.CreatedDate),
                        nameof(ServicesType.ModifiedDate),
                        nameof(ServicesType.Name),
                        nameof(ServicesType.Active),
                        nameof(ServicesType.GiftCertNo)
                    };


                    using (var sqlcopy = new SqlBulkCopy(connectionstring, SqlBulkCopyOptions.Default))
                    {
                        sqlcopy.BatchSize = 500;

                        sqlcopy.DestinationTableName = "[GiftCert]";
                        using (var reader = ObjectReader.Create(giftCerts, gcParameters))
                        {
                            sqlcopy.WriteToServer(reader);
                        }

                        sqlcopy.DestinationTableName = "[GcOutlet]";
                        using (var reader = ObjectReader.Create(gcOutlets, gcOutletParameters))
                        {
                            sqlcopy.WriteToServer(reader);
                        }

                        sqlcopy.DestinationTableName = "[ServicesType]";
                        using (var reader = ObjectReader.Create(services, serviceTypeParameters))
                        {
                            sqlcopy.WriteToServer(reader);
                        }
                    }
                }
            }
            return(response);
        }