public LicenseViewModel UpdateLicense(UpdateLicenseCommand command) { LicenseViewModel vm = new LicenseViewModel(); if (validator.ValidatePayment(command.SumInServer, command.Transaction.dSum, vm)) { Dictionary <string, Tuple <object, NHibernate.Type.IType> > param = new Dictionary <string, Tuple <object, NHibernate.Type.IType> >(); param.Add("@LicenseID", new Tuple <object, NHibernate.Type.IType>(command.LicenseID, NHibernate.NHibernateUtil.Int32)); repository.ExecuteSp("DeleteLicenseStocks", param); repository.ExecuteTransaction(session => { var license = session.Get <Entities.dbo.Userlicenses>(command.LicenseID); var transaction = AutoMapper.Mapper.Map <Entities.dbo.LicTransactions>(command.Transaction); session.Save(transaction); var user = session.Get <Entities.dbo.Users>(command.UserID); license.User = user; license.Transaction = transaction; license.tb_LicServices = new Licservices { Idlicservice = command.Idlicservice }; var service = session.Get <Entities.dbo.Licservices>(command.Idlicservice); license.dtExpirationDate = DateTime.Today.AddMonths(service.Imonths); license.dtActivationDate = DateTime.Today; license.dtPurchaseDate = DateTime.Today; session.Update(license); license.Licenseexchanges = new List <Entities.Lookup.Licenseexchanges>(); AddExchanges(license, command.Stocks.ToList()); session.Update(license); }); repository.Execute(session => { var licenseUpd = session.Query <Entities.dbo.Userlicenses>().Where(x => x.User.UserID == command.UserID).FirstOrDefault(); vm.License = AutoMapper.Mapper.Map <UserLicence>(licenseUpd); }); } return(vm); }
public IHttpActionResult Post(UpdateLicenseCommand command) { LicenseViewModel vm = new LicenseViewModel(); if (HttpContext.Current.Session["PaymentSum"] == null) { vm.Messages.Add(new Models.App.Message { LogLevel = Models.App.LogLevel.Error, Text = Messages.CalculationMethodNotUsed }); } else { command.SumInServer = (double)HttpContext.Current.Session["PaymentSum"]; command.Transaction.dSum = (double)HttpContext.Current.Session["PaymentSum"]; vm = service.UpdateLicense(command); HttpContext.Current.Session["PaymentSum"] = null; user.Licence = vm.License; HttpContext.Current.Session.Add("user", user); } return(Ok(vm)); }
public LicenseViewModel UpdateLicense(UpdateLicenseCommand command) { var vm = _licenseBL.UpdateLicense(command); return(vm); }
public async Task <ActionResult <UpdateLicenseUpdated> > Put(UpdateLicenseCommand command) { return(Ok(await Mediator.Send(command))); }