public IHttpActionResult Subscription(SubscriptionModel data) { int userId = GetUserId(); if (userId == 0) { reqResponse.ErrorMessages.Add("noUser", "Invalid Data"); return(Ok(reqResponse)); } using (SecurityUserRepository secUserRepo = new SecurityUserRepository()) { var currentUser = secUserRepo.GetById(userId); //data.Name = "ddd"; //data.PhoneNumber = 2525; data.Name = currentUser.FullName; data.PhoneNumber = int.Parse(currentUser.Telephone); } data.riderId = userId; if (string.IsNullOrEmpty(data.Name) || string.IsNullOrEmpty(data.PhoneNumber.ToString()) || data.PhoneNumber <= 0 || string.IsNullOrEmpty(data.Location) || string.IsNullOrEmpty(data.DateTimeStr)) { reqResponse.ErrorMessages.Add("invalidD", "Invalid Data"); return(Ok(reqResponse)); } data.DateTimeStr = data.DateTimeStr;// + " " + data.TimeStr; if (!string.IsNullOrEmpty(data.PromoCodeName)) { using (PromoCodeRepository promoRepo = new PromoCodeRepository()) { DomainModel.PromoCode promoCode = promoRepo.GetByName(data.PromoCodeName); if (promoCode != null) { if (promoCode.IsDeleted != true) { data.PromoCodeId = promoCode.Id; } } // return Ok(reqResponse); } } DateTime tempDate = new DateTime(); try { tempDate = DateTime.ParseExact(data.DateTimeStr, "dd/MM/yyyy hh:mm tt", CultureInfo.InvariantCulture); } catch (Exception) { tempDate = DateTime.ParseExact(data.DateTimeStr, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture); } //DateTime ddd = DateTime.ParseExact(data.DateTimeStr,"dd/MM/yyyy hh:mm tt", CultureInfo.InvariantCulture); using (SubscriptionRepository subscriptionRepo = new SubscriptionRepository()) { return(Ok( subscriptionRepo.AddUpdate(new DomainModel.SubscriptionV() { Name = data.Name, PhoneNumber = data.PhoneNumber, LocationStr = data.Location, Lat = data.Lat, Lng = data.Lng, PickDateTime = tempDate, DaysCount = data.DaysCount, PromoCodeId = data.PromoCodeId, UserId = data.riderId, PayMobId = data.PayMobId }) )); } }