Exemplo n.º 1
0
        public IActionResult AddProfile([FromBody] ProfileViewModel model)
        {
            var webRoot = _env.WebRootPath;
            //var path = System.IO.Path.Combine(webRoot, "TestFiles");
            string photoPath = System.IO.Path.Combine(webRoot, "Photo");
            string signPath  = System.IO.Path.Combine(webRoot, "Sign");
            var    result    = _profileManager.AddProfileDetail(model, photoPath, signPath);

            if (result.Status)
            {
                return(Ok(result));
            }
            else
            {
                return(StatusCode(404, result));
            }
        }
Exemplo n.º 2
0
        public ResponseModel <ContractViewModel> SaveCheckInForm(ContractViewModel _model, string imagePath, string signPath)
        {
            ResponseModel <ContractViewModel> response = new ResponseModel <ContractViewModel> {
                Data = new ContractViewModel()
            };

            try
            {
                var model = acmContext.CheckInForm.Where(e => e.Id == _model.CheckInModel.Id).FirstOrDefault();
                if (model != null)
                {
                    model.Id = _model.CheckInModel.Id;
                    model.SummeryOfTaskCompleted = _model.CheckInModel.SummeryOfTaskCompleted;
                    model.EmailAddress           = _model.CheckInModel.EmailAddress;
                    model.Name                  = _model.CheckInModel.Name;
                    model.Vin                   = _model.CheckInModel.Vin;
                    model.Year                  = _model.CheckInModel.Year;
                    model.PartsNeeded           = _model.CheckInModel.PartsNeeded;
                    model.PersonalItemInVehicle = _model.CheckInModel.PersonalItemInVehicle;
                    model.PhoneNumber           = _model.CheckInModel.PhoneNumber;
                    model.CustomerPartSupplied  = _model.CheckInModel.CustomerPartSupplied;
                    model.OdoMeter              = _model.CheckInModel.OdoMeter;
                    model.Models                = _model.CheckInModel.Models;
                    model.Make                  = _model.CheckInModel.Make;
                    model.CreatedOn             = DateTime.Now;
                    model.IsActive              = true;
                    model.IsCheckOut            = false;
                    model.StoreId               = _model.CheckInModel.StoreId;
                    acmContext.SaveChanges();
                    if (!string.IsNullOrEmpty(_model.ProfileModel.Signature))
                    {
                        _model.ProfileModel.CheckInId = model.Id;
                        var signResponse = profileManager.UpdateProfileDetail(_model.ProfileModel, imagePath, signPath);
                        if (signResponse.Status)
                        {
                            response.Data.ProfileModel = signResponse.Data;
                        }
                    }
                    // response.Data = list;
                    response.Data.CheckInModel = _model.CheckInModel;
                    response.Data    = _model;
                    response.Message = "Record updated successfully";
                    response.Status  = true;
                }
                else
                {
                    CheckInForm modelCheckInForm = new CheckInForm();
                    modelCheckInForm.SummeryOfTaskCompleted = _model.CheckInModel.SummeryOfTaskCompleted;
                    modelCheckInForm.EmailAddress           = _model.CheckInModel.EmailAddress;
                    modelCheckInForm.Name                  = _model.CheckInModel.Name;
                    modelCheckInForm.Vin                   = _model.CheckInModel.Vin;
                    modelCheckInForm.Year                  = _model.CheckInModel.Year;
                    modelCheckInForm.PartsNeeded           = _model.CheckInModel.PartsNeeded;
                    modelCheckInForm.PersonalItemInVehicle = _model.CheckInModel.PersonalItemInVehicle;
                    modelCheckInForm.PhoneNumber           = _model.CheckInModel.PhoneNumber;
                    modelCheckInForm.OdoMeter              = _model.CheckInModel.OdoMeter;
                    modelCheckInForm.Models                = _model.CheckInModel.Models;
                    modelCheckInForm.Make                  = _model.CheckInModel.Make;
                    modelCheckInForm.CustomerPartSupplied  = _model.CheckInModel.CustomerPartSupplied;
                    modelCheckInForm.CreatedOn             = DateTime.Now;
                    modelCheckInForm.IsActive              = true;
                    modelCheckInForm.StoreId               = _model.CheckInModel.StoreId;
                    modelCheckInForm.IsCheckOut            = false;
                    acmContext.Add(modelCheckInForm);
                    acmContext.SaveChanges();

                    if (!string.IsNullOrEmpty(_model.ProfileModel.Signature))
                    {
                        _model.ProfileModel.CheckInId = modelCheckInForm.Id;
                        var signResponse = profileManager.AddProfileDetail(_model.ProfileModel, imagePath, signPath);
                        if (signResponse.Status)
                        {
                            response.Data.ProfileModel = signResponse.Data;
                        }
                    }

                    _model.CheckInModel.Id      = modelCheckInForm.Id;
                    _model.CheckInModel.StoreId = modelCheckInForm.StoreId;
                    response.Data.CheckInModel  = _model.CheckInModel;


                    // response.Data = _model;
                    response.Message = "Record saved successfully";
                    response.Status  = true;
                }
            }
            catch (Exception ex)
            {
                response.Data    = null;
                response.Status  = false;
                response.Message = ex.Message;
            }

            return(response);
            // return responseModel;
        }